I am simply trying to paste text from the clipboard into a Table's column. The text has a couple of empty lines. For some reason it only paste the first line. Below is the text structure.
Nope. It still only paste the first line in sql server.
Hi,
Would you please tell us which version of SQL Server do you use ? I paste five lines including blank line in query windows, it display all the contents I paste. From your description, you want to insert values into table, right? Please check your columns's
maxLength to make sure all your content will store in the column, and then just use insert clause to insert data into table.
If I misunderstand your issue, please tell us more information about your problem. Thanks.
Best Regards,
Please mark the replies as answers if they help or unmark if not.
Feedback to us
Okay it seems to have worked when using the insert statement. The problem is that it seems to have ignored all the line breaks. It stored all the lines stuck together. Will it remember all the line breaks when I read it?
Okay it seems to have worked when using the insert statement. The problem is that it seems to have ignored all the line breaks. It stored all the lines stuck together. Will it remember all the line breaks when I read it?
Hi,
You can add "CHAR(13) + CHAR(10)" at the end of lines to achieve line break in the SQL Server. Please check below example in SSMS.
DECLARE @NewLineChar AS CHAR(2) = CHAR(13) + CHAR(10)
PRINT ('SELECT FirstLine1' +@NewLineChar + 'SELECT SecondLine2' )
GO
Because I am not just trying to read it in SSMS afterwards. I am talking about reading it later using maybe a SqlDataSource. Or are you talking about inserting the CHAR(2) variable when I insert the text the first time.
Please insert your value with CHAR(13) + CHAR(10) as line break into your table. Do you have any specially Symbol at the end of each line? If so, you could use replace() to add CHAR(13) + CHAR(10).
Best Regards,
Please mark the replies as answers if they help or unmark if not.
Feedback to us
No. It does not work. I used the query below Management studio and it stored the data just fine but when I read it later on in Visual Studio, it did not display line 2 on another line.
Additionally, even if it did, it would be quite easy to insert @NewLineChar when you have just a few line of data to store. It would be quite another process if you have pages of it.
I understand it has to be a specific solution so I will add that, during the write process in the INSERT query, whenever it reads a period (.) it would replace it with a line break.
Any ideas?
This is the Query I used.
<code>
DECLARE @NewLineChar AS CHAR(2) = CHAR(13) + CHAR(10)
INSERT INTO Lyric
(Lyric#, Artist, Title, Type, User#, Text)
VALUES
('2', '50 Cent', 'Many Men', '1', '1', 'Man we gotta go get something to eat man'+@NewLineChar
+'I’m hungry as a hog'
Code_warrior...
Member
251 Points
282 Posts
Pasting in Server Explorer and Management studio
Jan 07, 2013 09:06 PM|LINK
I am simply trying to paste text from the clipboard into a Table's column. The text has a couple of empty lines. For some reason it only paste the first line. Below is the text structure.
This is line 1.
This is line 2
Empty line here.
This is line 3.
g_mani
Contributor
2055 Points
586 Posts
Re: Pasting in Server Explorer and Management studio
Jan 08, 2013 04:09 AM|LINK
First copy your text structure into an excel sheet, so they willl be placed in separate cells. and select all -> copy
open your table in sql server then click left top corner and paste.
let me know if you have any problem with this.
Please Mark as Answer If this is helpful.
Code_warrior...
Member
251 Points
282 Posts
Re: Pasting in Server Explorer and Management studio
Jan 08, 2013 10:09 PM|LINK
Nope. It still only paste the first line in sql server.
Chen Yu - MS...
All-Star
21600 Points
2493 Posts
Microsoft
Re: Pasting in Server Explorer and Management studio
Jan 10, 2013 09:33 AM|LINK
Hi,
Would you please tell us which version of SQL Server do you use ? I paste five lines including blank line in query windows, it display all the contents I paste. From your description, you want to insert values into table, right? Please check your columns's maxLength to make sure all your content will store in the column, and then just use insert clause to insert data into table.
If I misunderstand your issue, please tell us more information about your problem. Thanks.
Best Regards,
Feedback to us
Develop and promote your apps in Windows Store
Code_warrior...
Member
251 Points
282 Posts
Re: Pasting in Server Explorer and Management studio
Jan 10, 2013 08:19 PM|LINK
Okay it seems to have worked when using the insert statement. The problem is that it seems to have ignored all the line breaks. It stored all the lines stuck together. Will it remember all the line breaks when I read it?
Chen Yu - MS...
All-Star
21600 Points
2493 Posts
Microsoft
Re: Pasting in Server Explorer and Management studio
Jan 11, 2013 02:00 AM|LINK
Hi,
You can add "CHAR(13) + CHAR(10)" at the end of lines to achieve line break in the SQL Server. Please check below example in SSMS.
DECLARE @NewLineChar AS CHAR(2) = CHAR(13) + CHAR(10) PRINT ('SELECT FirstLine1' +@NewLineChar + 'SELECT SecondLine2' ) GOReference on: http://blog.sqlauthority.com/2009/07/01/sql-server-difference-between-line-feed-n-and-carriage-return-r-t-sql-new-line-char/
http://stackoverflow.com/questions/31057/how-to-insert-a-line-break-in-a-sql-server-varchar-nvarchar-string
Best Regards,
Feedback to us
Develop and promote your apps in Windows Store
Code_warrior...
Member
251 Points
282 Posts
Re: Pasting in Server Explorer and Management studio
Jan 11, 2013 06:46 PM|LINK
Okay so I am getting you right. The above process, does it happen before or after the text is Inserted into the table from Excell?
Code_warrior...
Member
251 Points
282 Posts
Re: Pasting in Server Explorer and Management studio
Jan 11, 2013 06:51 PM|LINK
Because I am not just trying to read it in SSMS afterwards. I am talking about reading it later using maybe a SqlDataSource. Or are you talking about inserting the CHAR(2) variable when I insert the text the first time.
Chen Yu - MS...
All-Star
21600 Points
2493 Posts
Microsoft
Re: Pasting in Server Explorer and Management studio
Jan 14, 2013 09:43 AM|LINK
Hi,
Please insert your value with CHAR(13) + CHAR(10) as line break into your table. Do you have any specially Symbol at the end of each line? If so, you could use replace() to add CHAR(13) + CHAR(10).
Best Regards,
Feedback to us
Develop and promote your apps in Windows Store
Code_warrior...
Member
251 Points
282 Posts
Re: Pasting in Server Explorer and Management studio
Jan 18, 2013 01:07 AM|LINK
No. It does not work. I used the query below Management studio and it stored the data just fine but when I read it later on in Visual Studio, it did not display line 2 on another line.
Additionally, even if it did, it would be quite easy to insert @NewLineChar when you have just a few line of data to store. It would be quite another process if you have pages of it.
I understand it has to be a specific solution so I will add that, during the write process in the INSERT query, whenever it reads a period (.) it would replace it with a line break.
Any ideas?
This is the Query I used.
<code>
DECLARE @NewLineChar AS CHAR(2) = CHAR(13) + CHAR(10) INSERT INTO Lyric (Lyric#, Artist, Title, Type, User#, Text) VALUES ('2', '50 Cent', 'Many Men', '1', '1', 'Man we gotta go get something to eat man'+@NewLineChar +'I’m hungry as a hog'