如何在 SQL Server 2008 中编写 INSERT INTO 脚本



我想使用 SSMS 生成脚本。但这是不正确的。我想修复该代码。

这是代码:

 INSERT INTO [AdventureWorks2008].[HumanResources].[Department]
       ([Name]
       ,[GroupName]
       ,[ModifiedDate])
 VALUES
       (<Name, Name,>
       ,<GroupName, Name,>
       ,<ModifiedDate, datetime,>)
 GO

如何更正此代码?

谢谢。

INSERT INTO [AdventureWorks2008].[HumanResources].[Department]
       ([Name]
       ,[GroupName]
       ,[ModifiedDate])
 VALUES
       ('Some Name'
       ,'Some Group Name'
       ,GetDate())
 GO

必须填写适合你的方案的值。

您的值列表必须包含正确的值:

INSERT INTO [AdventureWorks2008].[HumanResources].[Department]
       ([Name]
       ,[GroupName]
       ,[ModifiedDate])
 VALUES
       ('name',
       'groupdate'
       '20131106')
 GO

你的语法是错误的

示例代码 :

 INSERT INTO [AdventureWorks2008].[HumanResources].[Department]
           ([Name]
           ,[GroupName]
           ,[ModifiedDate])
     VALUES
           ('Name',
           'GroupName',
           GetDate())
     GO

你的语法是错误的

VALUES
   (Name,
   ,GroupName,
   ,ModifiedDate)

还包括字段的值,例如

INSERT INTO [AdventureWorks2008].[HumanResources].[Department]
   ([Name]
   ,[GroupName]
   ,[ModifiedDate])
VALUES
   ('User1',
   'Group1',
   getdate())
GO

最新更新