Can someone tell me what is wrong in this query: I get error Msg 102, Level 15, State 1, Line 1 Incorrect syntax near

  • insert [User_Id],

    [Customer_Id],

    [User_Name],

    [Preferred_Name],

    [Email],

    [Mobile_Phone_1],

    [Mobile_Phone_2],

    [Mobile_Phone_3],

    [Phone_1_Status],

    [Phone_2_Status],

    [Phone_3_Status],

    [Password],

    [REMINDER_QUESTION],

    [REMINDER_ANSWER],

    [Registration_Date],

    [Registered_By],

    [Approval_date],

    [Approved_by],

    [Last_UpdateD],

    [Last_Updated_By],

    [Last_Sign_On_Tel],

    [Last_Sign_On_SMS],

    [Last_Sign_On_IB],

    [Status],

    [approved],

    [block],

    [TryCount],

    [user_flg],

    [ex_flg]

    into [e_onenew].[dbo].[Users]

    SELECT [User_Id],

    [Customer_Id],

    [User_Name],

    [Preferred_Name],

    [Email],

    [Mobile_Phone_1],

    [Mobile_Phone_2],

    [Mobile_Phone_3],

    [Phone_1_Status],

    [Phone_2_Status],

    [Phone_3_Status],

    [Password],

    [REMINDER_QUESTION],

    [REMINDER_ANSWER],

    [Registration_Date],

    [Registered_By],

    [Approval_date],

    [Approved_by],

    [Last_UpdateD],

    [Last_Updated_By],

    [Last_Sign_On_Tel],

    [Last_Sign_On_SMS],

    [Last_Sign_On_IB],

    [Status],

    [approved],

    [block],

    [TryCount],

    [user_flg],

    [ex_flg]

    from [e_one].[dbo].[Users]

  • Syntax should be like this:

    insert into [e_onenew].[dbo].[Users]

    (

    [User_Id],

    [Customer_Id],

    [User_Name],

    [Preferred_Name],

    [Email],

    [Mobile_Phone_1],

    [Mobile_Phone_2],

    [Mobile_Phone_3],

    [Phone_1_Status],

    [Phone_2_Status],

    [Phone_3_Status],

    [Password],

    [REMINDER_QUESTION],

    [REMINDER_ANSWER],

    [Registration_Date],

    [Registered_By],

    [Approval_date],

    [Approved_by],

    [Last_UpdateD],

    [Last_Updated_By],

    [Last_Sign_On_Tel],

    [Last_Sign_On_SMS],

    [Last_Sign_On_IB],

    [Status],

    [approved],

    [block],

    [TryCount],

    [user_flg],

    [ex_flg]

    )

    SELECT [User_Id],

    [Customer_Id],

    [User_Name],

    [Preferred_Name],

    [Email],

    [Mobile_Phone_1],

    [Mobile_Phone_2],

    [Mobile_Phone_3],

    [Phone_1_Status],

    [Phone_2_Status],

    [Phone_3_Status],

    [Password],

    [REMINDER_QUESTION],

    [REMINDER_ANSWER],

    [Registration_Date],

    [Registered_By],

    [Approval_date],

    [Approved_by],

    [Last_UpdateD],

    [Last_Updated_By],

    [Last_Sign_On_Tel],

    [Last_Sign_On_SMS],

    [Last_Sign_On_IB],

    [Status],

    [approved],

    [block],

    [TryCount],

    [user_flg],

    [ex_flg]

    from [e_one].[dbo].[Users]

  • Highly appreciated. Thank you very much

  • yes, your syntax is incorrect...

    it should be like this:

    INSERT INTO table_name

    SELECT coumn_names from table_name

    Follow the post of laurie, it will works

    _______________________________________________________________
    To get quick answer follow this link:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

  • You may find this site useful for basic SQL commands: http://www.w3schools.com/sql/sql_insert.asp

    Below is a direct quote.

    We can use the following SQL statement (without specifying column names):

    INSERT INTO Customers

    VALUES ('Cardinal','Tom B. Erichsen','Skagen 21','Stavanger','4006','Norway');

    or this SQL statement (including column names):

    INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode, Country)

    VALUES ('Cardinal','Tom B. Erichsen','Skagen 21','Stavanger','4006','Norway');

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply