I have string with back slash needed to insert into the MS Sql Server 2008 database using following insert sql query:
INSERT INTO Databsename.dbo.tblname
VALUES (Getdate(),
Getdate(),
'NewsHoroscopetest/voice/_06101214132pm014771957.wav',
20,
'014771045',
'01454545')
Here, Insertion failed due to back slash in the string value. I have also tried using double back slash. It shows following error:
Msg 8152, Level 16, State 14, Line 1
String or binary data would be truncated.
The statement has been terminated.
How can I escape the back slash in above sql?
The problem is nothing to do with the backslash. They do not need escaping
Probably the length of at least one of the values you are inserting is too long for the column you are inserting it into. The third value is 51 characters long and my guess is you are inserting it into a
varchar(50)column.If you double check that and find it is not the case then the error might be arising from a similar problem in an insert trigger on the table.