Click here to Skip to main content
15,885,145 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,

Once again i need your help , I want fetch data (id of table (int value)) from sql server 2008 database and use it as variable in c# windows form. i want to use that variable in another sql query to fetch entire row by matching that variable.
Posted

1 solution

SQL
Declare @id int
Select @id = IdCol1 from table1 where col2 = 'abc'


Now in variable '@Id' you have the valu. Now you can use it directly to other query like

SQL
select * from table2 where col1 = @Id


Or fetch it to int variable in c# and pass as parameter to other sp/query.
 
Share this answer
 
v2
Comments
ravish naik 1-Apr-14 0:51am    
thank you very much it worked :)
Er. Puneet Goel 1-Apr-14 0:52am    
Your welcome

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