Thursday, January 26, 2012

To save new line to vachar field of SQL Database Table

For various purposes we are in need to multi-line text in the database fields. It differs from OS to OS or databases to databases. Generally to save a multi-line text to a varchar field of a table in sql server database, we can use just two special characters:

char(13)+char(10)

This bondage of 13 years old boy and the 10 years old girl make a new position of the parent's line(Just love story to remember!!!!)



INSERT INTO [TestDB].[dbo].[testTable]
([TestID]
,[TestName]
)
VALUES
('ROW 2',
'Everybody should love his God'
+CHAR(13)+CHAR(10)+'No matter which one he believes'
+CHAR(13)+CHAR(10)+'God loves us so much.'
+CHAR(13)+CHAR(10)+'He is the almighty of this world')





If we execute the above query the table will accepts and holds the 2nd field with the 3 new line also. And the Select query with return them as intact.



No comments: