November 1, 2018 at 3:01 pm
gjoelson 29755 - Thursday, November 1, 2018 2:52 PMJoe Torre - Wednesday, October 31, 2018 5:18 PMHere is you query written as "insert into select"USE [SSSUTIL]
GO
INSERT INTO [dbo].[CustomerOrders]
([co_num]
,[cust_po]
,[co_line]
)
SELECT 38322, 'B123', 2;
GO
It doesn't matter if it's written as insert/select or insert/values, you still need to put single quotes around your strings.Joe, not sure how I would put quotes around all the values on an insert/select since I'm select directly from a table ?
Don't worry about adding quotes when selecting data from a table.
November 2, 2018 at 11:59 am
Lynn Pettis - Thursday, November 1, 2018 3:01 PMgjoelson 29755 - Thursday, November 1, 2018 2:52 PMJoe Torre - Wednesday, October 31, 2018 5:18 PMHere is you query written as "insert into select"USE [SSSUTIL]
GO
INSERT INTO [dbo].[CustomerOrders]
([co_num]
,[cust_po]
,[co_line]
)
SELECT 38322, 'B123', 2;
GO
It doesn't matter if it's written as insert/select or insert/values, you still need to put single quotes around your strings.Joe, not sure how I would put quotes around all the values on an insert/select since I'm select directly from a table ?
Don't worry about adding quotes when selecting data from a table.
So if it works when I do an insert with values using quotes, and it doesn't work using a select , does this have to do with the data type ?
November 2, 2018 at 12:58 pm
No.
The error says exactly what is wrong. Somewhere, either in the insert itself or maybe in a trigger, you're referencing a column that does not exist.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
November 2, 2018 at 1:28 pm
gjoelson,
It would behoove you to read the Microsoft SQL Server documentation on insert and the WC3 INSERT INTO and INSERT INTO SELECT documentation.
Viewing 4 posts - 31 through 33 (of 33 total)
You must be logged in to reply to this topic. Login to reply