Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Escape Character in SQL

Please forgive me as I am a bit of an sql noob. I am trying to do an insert using the following but am having a problem with the apostrophes. I have a lots of records to insert but many have the same problem. Is there a way of escaping them?

INSERT INTO  [dbo].[tb_Chefs] ([ChefHotelID], [HotelID], [ChefID],   
     [Position],  [GroupID])  
VALUES(N'b809a86e-f7f2-45b2-a240-0049f51509d7' ,N'14481', N'624', 
     N'Chef d'atelier', N'331')
GO

Any help much appreciated.

like image 704
Chin Avatar asked Feb 03 '26 05:02

Chin


1 Answers

'Chef d'atelier' becomes 'Chef d''atelier'

Just double them up

If a character string enclosed in single quotation marks contains an embedded quotation mark, represent the embedded single quotation mark with two single quotation marks.

like image 144
gbn Avatar answered Feb 05 '26 17:02

gbn



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!