views:

150

answers:

3

I have a really long string of text that I would like to update a particular column in a table. The update statement in sql query analyzer is on one long line currently. Is there a way to break up the update statment into multiple lines for easier reading of the update statement?

A: 

There's no problem having an UPDATE statement over multiple lines. Something like:

UPDATE yourtable
SET col1 = 
  'New value for column 1'
 ,col2 = 
  'New value for column 2'
WHERE col3 = 7

...is just fine.

Rob Farley
A: 

I think what you are after is string concatenation?

You can do an update like this:

Update YourTable
Set Col1 = 'Start of some long string' + 
'End of the long string'
Where SomeColumn = SomeValue
David Hall
+1  A: 

Query analyzer lets you put line breaks into literals:

insert into tbl (x) values ('hello
world')

But this inserts a CR as well. The other suggestion:

insert into tbl (x) values ('hello ' +
'world')

is standard procedure.

egrunin