I have the following query:
REPLACE sessions (session_id,session_data,expires) VALUES('pcal586o43604g0vpu5j22', 'id|i:111;user|N;s:9:\\\"admin\\\";admin_page|s:16:\"/control/\";', 1开发者_运维技巧317934461)
Which works fine with mysql but when using SQL SERVER it throws this error:
Msg 102, Level 15, State 1, Line 1 Incorrect syntax near 'session_id'.
Can anyone tell me anything that might be wrong with this query?
There is no command REPLACE
in SQL Server to replace values in a table.... you need to use a standard SQL UPDATE statement instead:
UPDATE dbo.sessions
SET session_id = 'pcal586o43604g0vpu5j22',
session_data = 'id|i:111;user|N;s:9:\\\"admin\\\";admin_page|s:16:\"/control/\";',
expires = 1317934461
WHERE .... (some condition here - otherwise you update ALL rows!)
T-SQL's REPLACE
function is a string function to replace a given substring inside another string with a replacement.
SQL Server has no equivalent to MySQL's REPLACE. You'd have to code the functionality manually.
In TSQL, REPLACE
is a string function, rather than a set-based operation.
In MySQL, REPLACE
is a MySQL extension to the SQL standard. It either inserts, or deletes and inserts.
精彩评论