Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

insert control characters in nvarchar or varchar from SQL script?

Given SQL Server 2012, how can I insert control characters (the ones coded under ASCII 32, like TAB, CR, LF) in a nvarchar or varchar column from a SQL script?

like image 257
Jeroen Wiert Pluimers Avatar asked Sep 17 '26 12:09

Jeroen Wiert Pluimers


1 Answers

Unless I miss something in the question you can do this using TSQL CHAR() function:

INSERT INTO MyTable(ColName) VALUES(CHAR(13) + CHAR(10))

Will insert CR/LF. Same for other codes.

Edit there is TSQL NCHAR() as well for Unicode characters.

like image 53
Yuriy Galanter Avatar answered Sep 19 '26 01:09

Yuriy Galanter



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!