2011-04-09 53 views
2

嗨當​​我嘗試使用db.ExecuteCommand運行.SQL腳本,我得到這個錯誤Incorrect syntax near the keyword 'IF'LINQ executecommand

我創建數據庫語句如下

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Users]') AND type in (N'U'))

CREATE TABLE dbo.Users(
[Id]  int PRIMARY KEY IDENTITY(1, 1) NOT NULL, 
[RoleId] int NOT NULL, 
[Name]  varchar(50) NOT NULL, 
[Gender] char(1) NULL, 
[Status] int NOT NULL, 

任何人都可以幫忙嗎?

回答

1

嘗試扔BEGIN之前「創建表」和END「創建表」語句

2

我刪除了GO和它的作品好後。 linq executeCommand'hate'GO :)