I whan to run this code, but it still doesn't work. :(
DECLARE @.MyText VARCHAR(1000)
SET @.MyText = 'SET IDENTITY_INSERT [Table1] ON ' + CHAR(13) + ' GO'
EXEC(@.MyText)
MSSQL doesn't like the "GO"
ThanksWhy do you need the GO?
USE Northwind
GO
SET NOCOUNT ON
CREATE TABLE myTable99(Col1 int IDENTITY(1,1), Col2 char(1))
GO
DECLARE @.mySQL99 VARCHAR(1000)
SET @.mySQL99 = 'SET IDENTITY_INSERT myTable99 ON INSERT INTO myTable99(Col1,Col2) SELECT 1,''A'''
+ ' SELECT * FROM myTable99'
SELECT @.mySQL99
EXEC(@.mySQL99)
GO
SET NOCOUNT OFF
DROP TABLE myTable99
GO
And why would you do dynamic sql for this anyway?
No comments:
Post a Comment