error in insert statement RRS feed

  • Question

  • User1869299283 posted

    insert into customer (Advance,status)values(@Advance,@status)where Name=@Name 

    i'm getting error in where clause..

    Tuesday, May 22, 2018 5:18 AM

All replies

  • User-1716253493 posted

    Inserting values is without where clause

    insert into customer (Advance,status)values(@Advance,@status)

    To insert from select query do like this

    insert into customer (Advance,status) SELECT Advance, status FROM TABLE2 where Name=@Name 

    Tuesday, May 22, 2018 6:22 AM
  • User77042963 posted

    It is an UPDATE:

     UPDATE customer 
    SET Advance=@Advance
    where Name=@Name 

    Tuesday, May 22, 2018 4:10 PM
  • User347430248 posted

    Hi Preetham Y,

    You cannot use Where clause in Insert query.

    You can use where clause if you are writing Insert Select query as other community member already informed you.

    So you need to change your logic and try to write the query in a correct way to solve this issue.

    You can get detailed information about 'Insert' from link below.

    INSERT (Transact-SQL)



    Wednesday, May 23, 2018 1:37 AM