I’m writing a query that inserts customer data into a MSSQL database. Very basic.
Unfortunately, I ran into a problem when trying to do the following:
INSERT INTO USERS(newid(),'BOB''S SELECT MARKETING')
I made sure to escape my quotes, but the server is still seeing SELECT as a reserved keyword. I don’t want to have to wrap a bunch of reserved words in brackets. Is there a cleaner way of getting my data in the database intact and not mangled by brackets?
I appreciate your help.
Thank you!
You have several choices of syntax here. Using the one in your code sample, you forgot the VALUES keyword. For example:
You can also use the insert into / select statement like below if you are inserting a value into each one of the table’s columns:
Or you can use the insert into / select statement and specify the columns you are inserting: