Click here to Skip to main content
15,867,939 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
I have a table with some 30 columns.
I have written a storeprocedure to insert data into Table using joins from various table.
in join i have where condition i.e
SQL
insert into Test([col1],[col2])
select a.Name,b.sub
from IdTable b
join  Nametable a ON b.no = a.no

no is PK in IdTable.
query is executing but (0 row(s) affected)
Please help
Posted
Updated 18-Jun-12 23:49pm
v2
Comments
member60 19-Jun-12 6:01am    
"query is executing but (0 row(s) affected)"
I don't think so.your query will not get executed any , right?

1 solution

Please try this one

SQL
INSERT INTO Test([col1],[col2])
(SELECT a.Name AS [col1],b.sub AS [col2] 
 FROM IdTable b INNER JOIN Nametable a ON b.no = a.no)


IF ANY PROBLEM THEN REPLY WITH PROBLEM AND SOLVED THEN REPLY MUST
 
Share this answer
 
v3
Comments
rohit24c 19-Jun-12 7:06am    
Thanks Pradip Yeah the query has been solved.I had to apply left join.
But if the same query i am using in a store procedure it is not inserting any data.
Please help
Pradip Jadhav, India 20-Jun-12 2:29am    
@rohit24c-can you give query as it is so i try to run in my place and reply you with problem with store procedure

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