Click here to Skip to main content
15,912,897 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

I have to pass parameters to insert and also some fields need to select and insert from other tables.

Insert into TABLEA (No,Name,CName) values (@ID,@NAME,(select CNAME FROM TableB where ID =1 ))

It's not work. Have any other solution for this?

Please help me...

Thanks & Regards,

Vineetha
Posted

Hi,

Try this...


SQL
Insert into TABLEA (No,Name,CName) 
SELECT @ID,@NAME,CNAME FROM TableB where ID =1


Hope this will help you.

Cheers
 
Share this answer
 
Please try like this,

Insert into TABLEA (No,Name,CName) select @ID,@NAME,(select CNAME FROM TableB where ID =1 )


I Think it works.
 
Share this answer
 
v3
Insert into TABLEA (No,Name,CName)select CNAME FROM TableB where ID =1
 
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