2

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?

Rob Farley
  • 15,625
  • 5
  • 44
  • 58
Joo Park
  • 3,115
  • 4
  • 27
  • 31

3 Answers3

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