Inserting row error, incorrect syntax near '<'

I've never used SQL Servre before so this is completely new to me.

I have the following insert statement:

INSERT INTO 
    [dbo].[WEB_static_pages]([url], [template], [title], [metadesc],[metakey])
VALUES
    (<url, varchar(255), "test">,
     <template, varchar(255), "test.php">,
     <title, nvarchar(255), "test title">,
     <metadesc, text, "test meta">,
     <metakey, text, "test meta key">)
GO

The following has three 'tooltip' warnings though in SQL Server Management Studio:

Incorrect syntax near '<'" and "varchar is not a recognised built in function name

Can anyone suggest what the issue is here? How can I reformat my statement to suit SQL Server Management Studio?


When inserting values using SQL Server, you need only specifies the actual data you want inserted in the VALUES clause. So use a comma-separated list of values in your case, and wrap it in parentheses:

INSERT INTO [dbo].[WEB_static_pages]
           ([url]
           ,[template]
           ,[title]
           ,[metadesc]
           ,[metakey])
 VALUES (
        'test',
        'test.php',
        'test title',
        'test meta',
        'test meta key')

重写它像这样,它应该工作:

INSERT INTO [dbo].[WEB_static_pages]
           ([url]
           ,[template]
           ,[title]
           ,[metadesc]
           ,[metakey])
     VALUES
           ('test'
           ,'test.php'
           ,'test title'
           ,'test meta'
           ,'test meta key')
GO
链接地址: http://www.djcxy.com/p/94490.html

上一篇: 多个INSERT查询转换为一个查询

下一篇: 在'<'附近插入行错误,语法不正确