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?
Asked
Active
Viewed 4,164 times
2
-
breakup the update statement or the single string for one column update? – Nick Kavadias Jan 28 '10 at 01:37
3 Answers
2
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
- 24,650
- 8
- 50
- 93
1
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
- 32,624
- 10
- 90
- 127
0
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
- 15,625
- 5
- 44
- 58