Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Paste text with newlines in it in Sql Server management studio 2008 'edit top 200 rows' window in a varchar(200) column

I have to manually edit a few records in the (SQL 2008) database.

I open up SSMS, rightclick on the table, choose 'edit top 200 rows', locate the right record and column, paste my text (which is something like this, bold only for presentation):

Hi Michel,

Congratulations!

John

And all that is stored is 'Hi Michel,'

all the lines but the first are 'lost'.

Is there a nice feature to paste the ENTIRE text in the field?

like image 320
Michel Avatar asked Dec 09 '10 08:12

Michel


People also ask

How do I change the edit top 200 rows in SQL?

By right-clicking on the table name I select the command "Edit Top 200 Rows". By the way, the number of rows loaded with this command can be changed by the option "Tools > Options > SQL Server Object Explorer > Commands > Value for Edit top <n> Rows command". If 0 is entered, all rows or options are loaded.


2 Answers

I'm not aware of a way to do this manually so i think your stuck with writing SQL. For that as your editing records you could write it as an update statement.

String literals can span multiple lines, so you should be able to paste your updated in without reformatting it.

e.g.

UPDATE your_table
SET field_to_update = 'Hi Michel,

Congratulations!

John'
WHERE field = criteria_to_match
like image 96
kevchadders Avatar answered Sep 28 '22 09:09

kevchadders


You'd be better working in script. You can just write an update:

UPDATE <Table Name>
SET Column = 'Hi Michel,

Congratulations!

John'
WHERE <Key column conditions>

I don't believe there's any way to do this via the Edit pane.

like image 36
Damien_The_Unbeliever Avatar answered Sep 28 '22 09:09

Damien_The_Unbeliever