为什么SQL Query不会运行?

时间:2014-04-16 15:42:42

标签: c# sql sql-server sql-server-2005 visual-studio-2012

我正在使用SQL Server 2005。

以下是我遵循的步骤:

  1. 右键单击数据连接。
  2. 添加了与服务器的连接。
  3. 选定的Microsoft SQL Server(SQL客户端)。
  4. 创建了数据库。
  5. 右键单击表格部分。
  6. 按下添加新查询。
  7. 插入SQL语句。
  8. 按下执行SQL语句。
  9. 我使用此SQL语句尝试运行它:

    CREATE TABLE [dbo].[Title](
        [id] [int] IDENTITY(1000,1) NOT NULL,
        [name] [nvarchar](30) NULL,
        [artist] [nvarchar](40) NULL,
        [price] [money] NULL,
        [length] [float] NULL,
        CONSTRAINT [PK_title] PRIMARY KEY CLUSTERED  ( [id] ASC )
    ) ON [PRIMARY]
    GO
    
    INSERT INTO [dbo].[Title] ([name],[artist], [price], [length]) 
    VALUES (N'Dhoom Machale', N'Aditi Singh Sharma', CAST(5.99 AS Money), 7.45)
    
    INSERT INTO [dbo].[Title] ([name],[artist], [price], [length]) 
    VALUES (N'Mat Maari', N'Kunal Ganjawala, Sunidhi Chauhan', CAST(4.50 AS Money), 6.45)
    
    INSERT INTO [dbo].[Title] ([name],[artist], [price], [length]) 
    VALUES (N'Paani Paani',N'Honey Singh', CAST(2.90 AS Money), 4.5)
    
    INSERT INTO [dbo].[Title] ([name],[artist], [price], [length]) 
    VALUES (N'Dhanush Sachin Anthem', N'Dhanush', CAST(3.50 AS Money), 4.45)
    
    INSERT INTO [dbo].[Title] ([name],[artist], [price], [length]) 
    VALUES (N'Hamari Atariya Pe', N'Rekha Bhardwaj', CAST(4.00 AS Money), 4.43)
    
    INSERT INTO [dbo].[Title] ([name],[artist], [price], [length]) 
    VALUES (N'Kabhi Jo Badal Barse', N'Arijit Singh', CAST(3.40 AS Money), 5.05)
    
    INSERT INTO [dbo].[Title] ([name],[artist], [price], [length]) 
    VALUES (N'Do Rang Duniya Ke Aur Do Raste', N'Mukesh', CAST(2.75 AS Money), 4.35)
    
    INSERT INTO [dbo].[Title] ([name],[artist], [price], [length]) 
    VALUES (N'Mera Joota Hai Japani', N'Mukesh', CAST(1.97 AS Money), 5.15)
    
    INSERT INTO [dbo].[Title] ([name],[artist], [price], [length]) 
    VALUES (N'Full Jhol', N'Mika Singh, Akasa Singh', CAST(2.45 AS Money), 5.05)
    
    INSERT INTO [dbo].[Title] ([name],[artist], [price], [length]) 
    VALUES (N'Kaddu Katega', N'Antara Mitra', CAST(3.24 AS Money), 4.25)
    
    INSERT INTO [dbo].[Title] ([name],[artist], [price], [length]) 
    VALUES (N'Tujse Door Jo Hota Hunn',N'Gajendra Verma', CAST(2.45 AS Money), 3.45)
    
    INSERT INTO [dbo].[Title] ([name],[artist], [price], [length]) 
    VALUES (N'Chura Liya Hai Tumne Jo Dil Ko',N'Asha Bhosle, Mohammad Rafi', CAST(3.55 AS Money), 4.05)
    
    INSERT INTO [dbo].[Title] ([name],[artist], [price], [length]) 
    VALUES (N'Deewana Mujh Sa Nahin',N'Mohammad Rafi', CAST(4.35 AS Money), 4.25)
    

    我得到的错误是this

    为什么我收到此错误?

1 个答案:

答案 0 :(得分:4)

取出GO声明。

Visual Studio / SQL Server数据工具使用ADO.NET数据提供程序。数据库引擎无法识别GO,只能由Management Studio和OSQL / SQLCMD识别。

SQL Server GO Keyword