Stored procedure (incrementing columns)
Posted: Tue Sep 19, 2006 9:02 am
I need to write a stored procedure using this query:
{
select col016, count(distinct contactid)
from sublist_732 s with(nolock) join mydatabase.dbo.mytable e with(nolock)
on s.contactid = e.col014
group by col016
order by col016
}
except instead of just getting a count for column16, (which is col016), i'll need to get it for all columns up to column 251 (which would be col251). So i'll need some sort of way to increment it using a variable so i can return a count for all columns from col016 to col251.. and i'm not sure how to do that.
If there's any confusion in my post, reply back with questions.
{
select col016, count(distinct contactid)
from sublist_732 s with(nolock) join mydatabase.dbo.mytable e with(nolock)
on s.contactid = e.col014
group by col016
order by col016
}
except instead of just getting a count for column16, (which is col016), i'll need to get it for all columns up to column 251 (which would be col251). So i'll need some sort of way to increment it using a variable so i can return a count for all columns from col016 to col251.. and i'm not sure how to do that.
If there's any confusion in my post, reply back with questions.