rowmark
asked on
Count of Records
Hi, I have a stored proc that will accept zipcode and radius as parameters
and return list of zipcodes based on the params.
I am inserting the results into a different table. I have couple of questions,
How do I loop through the records from above and insert into another table
How do I get a count of records thrown by the query.
If the count is >0 I want to insert into another table
and return list of zipcodes based on the params.
I am inserting the results into a different table. I have couple of questions,
How do I loop through the records from above and insert into another table
How do I get a count of records thrown by the query.
If the count is >0 I want to insert into another table
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
insert my_other_table (< column list >)
select <column list>
from #my_zipcodes
where <conditions>
if there is nothing in #my_zipcodes that satisfy the <conditions> then it is a empty set and nothing is added.
if there is possibility of duplicate rows that might already exists then would have to extend those <conditions> with :
insert my_other_table (< column list >)
select <column list>
from #my_zipcodes Z
where <conditions>
AND not exists (select NULL from my_othertable O where O.zipcode = Z.zipcode and O.suburb = Z.suburb)