This question already has answers here:
Way to insert text having ' (apostrophe) into a SQL table (8 answers)
Closed 8 days ago.
I am trying to manually add a item into my table in SQL Server by using insert into
statements, but I get an error.
Normally a string is added using a single apostrophe in front and back of the string in SQL Server, but I am adding a value which has an apostrophe in between (like can't
), how to add this in the T-SQL insert into
statement?
I did try 3 different methods to insert but still failed
insert into orders (6, 'microsoft surface pro', 'IDHGHRTUJ'''123456', 1, 8)
insert into orders (6, 'microsoft surface pro', 'IDHGHRTUJ'123456', 1, 8)
insert into orders (6, 'microsoft surface pro', "IDHGHRTUJ'123456", 1, 8)
I need output in this of the string with the apostrophe in iot
2条答案
按热度按时间k5hmc34c1#
You can insert single quote in database by using double single quote while providing values as shown below:
Here is the output after insert
You can find the live demo here
prdp8dxp2#
Another way is to use CONCAT() within your insert statement.
Used a temp table #orders for testing