user2978983
user2978983

Reputation: 254

Insert into table With select and multiple value SQL server

guys im trying to insert into a table with multiple value.

i want insert into purchasing table where customerID is gained from Customer table and the SourceID is always 1 because it its default. i try query like this

insert into purchasing (customerID,SourceID) select customerID from Customer where    ************,'1'

but it returns erorr, can u guys help me, how to insert into table with multiple select and default insert

note: ******* is any condition

Upvotes: 0

Views: 177

Answers (3)

jtorrescr
jtorrescr

Reputation: 627

It is due to you have couple of errors in your sql. 1. You have the closing ) but never opened it. 2. Include the default value in your query

insert into purchasing (customerID,SourceID) select customerID, 1 from Customer where ???

Upvotes: 1

Girish Vadhel
Girish Vadhel

Reputation: 745

You are writing wrong sql query syntax. Your sql query should be something like:

insert into purchasing (customerID,SourceID) select customerID, 1 from Customer where *** 

Upvotes: 4

Paul Sturm
Paul Sturm

Reputation: 2138

Try select customerID, 1 from Customer

Upvotes: 1

Related Questions