Click here to Skip to main content
15,879,326 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello all..

I am having a problem with sql.

SQL
INSERT INTO Customers (ContactName, CustomerName, Country) Values  ('Islamabad',
SELECT SupplierName, Country FROM Suppliers);


I want to insert contactname manually and and want to insert SupplierName and Country from the Suppliers table in Customer table.

I am getting Syntax Error Near Select.
Posted

We usually do insert like the bellow query. Do accordingly
SQL
INSERT INTO Customers (ContactName, CustomerName, Country) 
SELECT 'Islamabad',SupplierName, Country FROM Suppliers
 
Share this answer
 
v2
Comments
hypermellow 10-Jan-14 5:06am    
You beat me to a great answer, have 5!
Sibasisjena 10-Jan-14 5:09am    
Thank you very much :)
Try something like this ...
SQL
INSERT INTO Customers (ContactName, CustomerName, Country)
SELECT 'Islamabad', SupplierName, Country FROM Suppliers
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900