this is my sp
UPDATE Con
SET Category1code =c1.Category1Name, Category2Code=c2.Category2Name
FROM Contacts Con
INNER JOIN Category1 As c1
ON Con.Category1Code = c1.Category1Code
Inner Join Category2 As c2
ON Con.Category2Code = c2.Category2Code
just i want write above sp into simple query like
SqlConnection Con=new SqlConnection();
SqlCommand cmd=New SqlCommand("how to write above sp here",con);
please give me solution
thanx in advance.
Pradip PandeyPosted Mar 19, 2013, 6:32 AM
Ajinkya BanPosted Mar 19, 2013, 7:32 AM
Ajinkya BanPosted Mar 19, 2013, 7:32 AM
Pradip PandeyPosted Mar 19, 2013, 7:21 AM
This is because previously you have updated Category1code & Category2code with categoryname.
Hope it will help.
Vishal GilbilePosted Mar 19, 2013, 7:07 AM
You just need to call the procedure following is the way for calling.
SqlConnection con=new SqlConnection("Your Connection string over here");
SqlCommand cmd=new SqlCommand("ProcedureName",con);
cmd.CommandType=CommandType.StoredProcedure;
//if your procedure accepts parameter you need to add it for instance if my proc accepts //a parameter name @name I will add it in the following way.
cmd.Parameter.AddWithValue("@name","value");
// Rest of the execution is same what we do for single line query.
With Regards,
Vishal Gilbile
Ajinkya BanPosted Mar 19, 2013, 6:51 AM
Pradip PandeyPosted Mar 19, 2013, 6:47 AM
Please mark it as Accepted Answer, if it really helped you.
Hope it will help.
Ajinkya BanPosted Mar 19, 2013, 6:37 AM