Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
ssunny
Posting Yak Master
133 Posts |
Posted - 2012-09-19 : 16:20:42
|
Hello Guys,I am looking for a way to rewrite following store procedure using CTE or any other better solution.CREATE PROCEDURE dbo.getrecords asbegin declare @tid int create table #testtable (tid int, ttext varchar(300)) declare tcursor cursor for select tid from test open tcursor fetch tcursor into @tid while @@fetch_status = 0 begin insert into #testtable (tid, ttext) exec ('dbo.some_store_proc ' + @tid ) fetch tcursor into @tid end close tcursor deallocate tcursor SELECT a,b,cFROM test t (nolock) join #testtable t1 on t1.tid = t.tid END drop table #testtable go Thanks |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|
|