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 |
mrm23
Posting Yak Master
198 Posts |
Posted - 2010-08-26 : 07:54:12
|
Hi All,I have a procedure which calculates percentage. so i have two temp tables.One to fetch the data from DB and the other to store the calculation.finally my result set would beselect * from #tempThe same procedure when run with a table variable (@temp) , works fine and dataset also shows the fields.I found this strange. will usage of temporary tables cause this problem?Please suggest me.here is a sample:1st code does not work. the data set will be blank. The 2nd one works fine.***************************************************************************************create proc temptabletestasbegincreate table #temp(id int,name varchar(20))insert into #tempselect 1,'AAA' union allselect 2,'BBB' union allselect 3,'CCC' union allselect 4,'DDD'select * from #tempend*****************************************************************************create proc tablevariabletestasbegindeclare @temp table(id int,name varchar(20))insert into @tempselect 1,'AAA' union allselect 2,'BBB' union allselect 3,'CCC' union allselect 4,'DDD'select * from @tempend |
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2010-08-26 : 08:16:26
|
Huh -- works fine for mecreate proc temptabletestasbegincreate table #temp(id int,name varchar(20))insert into #tempselect 1,'AAA' union allselect 2,'BBB' union allselect 3,'CCC' union allselect 4,'DDD'select * from #tempendGOEXEC dbo.tempTableTest Resultsid name1 AAA2 BBB3 CCC4 DDD Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2010-08-26 : 08:17:30
|
Maybe you have an error on your proc to 'which calculates percentage'Feel free to post the code.Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
|
|
mrm23
Posting Yak Master
198 Posts |
Posted - 2010-08-26 : 08:38:30
|
Hi, Thanks for the reply. I tried to create a Dataset for this but i did not get any fields.The procedure alone when run works fine.I think the prob is using the temp table with proc and trying to push that into a dataset.advice me if i am wrong. |
|
|
|
|
|
|
|