简体   繁体   中英

Msg 102, Level 15, State 1, Line 1 Incorrect syntax near '('

I am trying to query to insert in a table and i keep getting this message:

The Query is:

INSERT INTO A_USER(PK,status,login_id,HASHBYTES('md5', password),fk_role,last_update_ts,last_update_by,created_by)
VALUES (2,1,'abc', 'abc',2,'3/15/2012 12:21:46 PM','abc','abc')
INSERT INTO EMP_USER(PK,status,login_id,password,fk_role,last_update_ts,last_update_by,created_by)
VALUES (2,1,HASHBYTES('md5', password),'abc','abc',2,'3/15/2012 12:21:46 PM','abc','abc')

insert statement works like that

insert into table (col1, col2) values (val1, val2)

Put HASHBYTES('md5', password) in the values part and name that column in the column part

Your issue is with this line HASHBYTES('md5', password) , you want to use the HASHBYTES in the VALUES area of your INSERT .

INSERT INTO A_USER
(
    PK
    ,status
    ,login_id
    ,[password] -- change to the name of your column.
    ,fk_role
    ,last_update_ts
    ,last_update_by
    ,created_by
)
VALUES 
(
    2
    ,1
    , 'abc'
    ,HASHBYTES('md5', 'abc') -- place your password to be hashed where 'abc' is.
    ,2
    ,'3/15/2012 12:21:46 PM'
    ,'abc'
    ,'abc'
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM