Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 insert values with '

Author  Topic 

sphericalx
Starting Member

10 Posts

Posted - 2008-12-31 : 02:20:34
how can i insert a values with ' into the database?

data type for name is varchar
value to be entered in: M'C

insert tblmembers (name) values ('M'C') <--- i will get a error msg since ' is being read as a quotation

Below is the error msg.

Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near 'C'.
Server: Msg 105, Level 15, State 1, Line 1
Unclosed quotation mark before the character string ')
'.


bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2008-12-31 : 02:25:16
try like this
insert tblmembers(name) values ('m''c')
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-31 : 02:36:05
also see this

http://sqlblogcasts.com/blogs/madhivanan/archive/2008/02/19/understanding-single-quotes.aspx
Go to Top of Page
   

- Advertisement -