String Declaration

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have an SQL statement which is quite long. I want to declare a string
variable with this SQL statement and I want to have span multiple lines. I
could scrunch it all up and place it on a single line, but then the SQL
statement would be unreadable. There was a way to do this in VB, but how do
you do this is C#?

I want it to look something like this in the code.

string mySQL = "select 'Anchor' as Anchor_NonAnchor, combo.PROCESS_GROUP,
combo.COMBINATION, cf.CHARTFIELD,
grp.COMBO_DEFN_NAME, ' ' as Tree_Name, ' ' as
Node_Name,
cf.SEQUENCE_NBR_6, cval.SELECT_VALUE as Range_From,
' ' as
Range_To
from gapsc.ps_combo_grrul_tbl combo,
gapsc.ps_combo_rule_tbl Rul,
gapsc.ps_combo_group_tbl grp,
gapsc.ps_combo_cf_tbl cf,
gapsc.ps_combo_val_tbl cval
where Rul.EFFDT_TO = '2099-01-01'
and rul.combination = combo.combination
and grp.setid = rul.setid
and combo.setid = cf.setid
and rul.combination = cf.combination
and rul.combination = cval.combination
and grp.Process_Group = combo.Process_Group
and grp.combo_defn_name = rul.combo_Defn_Name
and cf.SETID = cval.SETID
and cf.COMBINATION = cval.COMBINATION
and cf.SEQUENCE_NBR_6 = cval.SEQUENCE_NBR_6
and cf.TREE_NAME = ' ' ";

Thanks in advance!!
 
string mySQL = @"Some long
text with "" double quote escapting of single quotes
that goes on and on and on";

Or use an sp (or the equivalent name for your database) ;-p

(oh don't look at me like that... someone was bound to say it!)

Marc
 
Marc said:
string mySQL = @"Some long
text with "" double quote escapting of single quotes
that goes on and on and on";

Or use an sp (or the equivalent name for your database) ;-p

(oh don't look at me like that... someone was bound to say it!)

Marc

Just for completeness, you can also continue your string onto the next
line:

string mySQL = "SELECT field1, field2 " +
" FROM table " +
"WHERE Id = @Id";
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top