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.
| Author |
Topic |
|
Sun Foster
Aged Yak Warrior
515 Posts |
Posted - 2009-11-05 : 16:10:39
|
| To learn sp_executesql, I create a small code. It works as below.CREATE TABLE [dbo].[#A]( [authno] [nchar](10) NULL, [Authname] [nvarchar](50) NULL) ON [PRIMARY]INSERT INTO #A (AUTHNO, AUTHNAME)VALUES('444' + '~', 'EEE')Once run sp_executesq, got an error said Incorrect syntax near '444'. How to fix it?CREATE TABLE [dbo].[#A]( [authno] [nchar](10) NULL, [Authname] [nvarchar](50) NULL) ON [PRIMARY]DECLARE @sql nvarchar(200)set @sql = N'INSERT INTO #A (AUTHNO, AUTHNAME)VALUES('444' + '~', 'EEE')'exec sp_executesql @sql |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-11-05 : 16:16:07
|
inside you have to mask a quote with another quote.''444''+''~'',''EEE'' No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|