473,320 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How To: Do multi-line string vars?

I'm running into a situation where I want to take a multi-line SQL
statement and include it as a string in my code. I know that I can do
something like

strSQL = "SELECT * "
strSQL &= "FROM tbl.dbo.MyTable, "
strSQL &= " tbl.dbo.MyTable2 "
strSQL &= "WHERE MyTable.ID = MyTable2.ID "
strSQL &= "ORDER BY Date DESC"

but is there a way to do something like

strSQL = ::BOF::
SELECT *
FROM tbl.dbo.MyTable,
tbl.dbo.MyTable2
WHERE MyTable.ID = MyTable2.ID
ORDER BY Date DESC
::EOF::

?

I know it sounds like a petty issue, but some of these SQL statements
are scores of lines long, and are subject to overhaul from time to
time... if there was a way to do what I'm looking for, I could save some
5-10 minutes of formatting headaches. I'm afraid I know the answer
already (as "No") but I figured it wouldn't hurt to ask.

Thanks,
Scott
Jul 21 '05 #1
2 2414
Ho Scott

I may not have the exact answer you are looking for, but a possible
alternative

Use the StringBuilder class ,
This will give you 2 great abilities
1. You can change the lines fairly quickly and easy
2. Formatting, very handy feature

Exp.
StringBuilder sbSql = new StringBuilder() ;
sbSql.Append("SELECT * ") ;
sbSql.AppendFormat("FROM {0}, ","tbl.dbo.MyTable") ; //just to illustrate
sbSql.Append(" WHERE MyTable.ID = MyTable2.ID ")

This may help in inserting, altering strings as well as passing dynamic
related information
Henk
"Scott McNair" <sc**********@sfmco.takethispartout.com> wrote in message
news:Xn*******************@207.46.248.16...
I'm running into a situation where I want to take a multi-line SQL
statement and include it as a string in my code. I know that I can do
something like

strSQL = "SELECT * "
strSQL &= "FROM tbl.dbo.MyTable, "
strSQL &= " tbl.dbo.MyTable2 "
strSQL &= "WHERE MyTable.ID = MyTable2.ID "
strSQL &= "ORDER BY Date DESC"

but is there a way to do something like

strSQL = ::BOF::
SELECT *
FROM tbl.dbo.MyTable,
tbl.dbo.MyTable2
WHERE MyTable.ID = MyTable2.ID
ORDER BY Date DESC
::EOF::

?

I know it sounds like a petty issue, but some of these SQL statements
are scores of lines long, and are subject to overhaul from time to
time... if there was a way to do what I'm looking for, I could save some
5-10 minutes of formatting headaches. I'm afraid I know the answer
already (as "No") but I figured it wouldn't hurt to ask.

Thanks,
Scott

Jul 21 '05 #2
2 suggestions:

1) write the SQL-String in an external file and read it in at runtime
2) use stored procedures in the DB ;-)

Jon

"Scott McNair" <sc**********@sfmco.takethispartout.com> schrieb im
Newsbeitrag news:Xn*******************@207.46.248.16...
I'm running into a situation where I want to take a multi-line SQL
statement and include it as a string in my code. I know that I can do
something like

strSQL = "SELECT * "
strSQL &= "FROM tbl.dbo.MyTable, "
strSQL &= " tbl.dbo.MyTable2 "
strSQL &= "WHERE MyTable.ID = MyTable2.ID "
strSQL &= "ORDER BY Date DESC"

but is there a way to do something like

strSQL = ::BOF::
SELECT *
FROM tbl.dbo.MyTable,
tbl.dbo.MyTable2
WHERE MyTable.ID = MyTable2.ID
ORDER BY Date DESC
::EOF::

?

I know it sounds like a petty issue, but some of these SQL statements
are scores of lines long, and are subject to overhaul from time to
time... if there was a way to do what I'm looking for, I could save some
5-10 minutes of formatting headaches. I'm afraid I know the answer
already (as "No") but I figured it wouldn't hurt to ask.

Thanks,
Scott

Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

37
by: ajikoe | last post by:
Hello, Is anyone has experiance in running python code to run multi thread parallel in multi processor. Is it possible ? Can python manage which cpu shoud do every thread? Sincerely Yours,...
4
by: Frank Jona | last post by:
Intellisense with C# and a multi-file assembly is not working. With VB.NET it is working. Is there a fix availible? We're using VisualStudio 2003 Regards Frank
12
by: * ProteanThread * | last post by:
but depends upon the clique: ...
6
by: cody | last post by:
What are multi file assemblies good for? What are the advantages of using multiple assemblies (A.DLL+B.DLL) vs. a single multi file assembly (A.DLL+A.NETMODULE)?
6
by: Joe | last post by:
I have 2 multi-list boxes, 1 displays course categories based on a table called CATEGORIES. This table has 2 fields CATEGORY_ID, CATEGORY_NAME The other multi-list box displays courses based on...
5
by: bobwansink | last post by:
Hi, I'm relatively new to programming and I would like to create a C++ multi user program. It's for a project for school. This means I will have to write a paper about the theory too. Does anyone...
17
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello everyone, Wide character and multi-byte character are two popular encoding schemes on Windows. And wide character is using unicode encoding scheme. But each time I feel confused when...
0
by: Sabri.Pllana | last post by:
We apologize if you receive multiple copies of this call for papers. *********************************************************************** 2008 International Workshop on Multi-Core Computing...
2
by: Aussie Rules | last post by:
Hi, I have a site that Iwant to either display my text in english or french, based on the users prefernces ? I am new to webforms, but I know in winforms, this is pretty easy with a resource...
14
by: =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
As far as I know, the C Standard has no mention of multi-threaded programming; it has no mention of how to achieve multi-threaded programming, nor does it mention whether the language or its...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.