Updating long string through SQL Server Query Analyzer
I have a really long string of text that I would like to update a particular column in a table. The upda开发者_JAVA技巧te 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?
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.
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.
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
精彩评论