This is a migrated thread and some comments may be shown as answers.

Using temporary tables or table variables in SP

2 Answers 91 Views
Report Designer (standalone)
This is a migrated thread and some comments may be shown as answers.
Mateusz
Top achievements
Rank 1
Mateusz asked on 06 Apr 2013, 12:10 PM
Hi,

I have encountered a little problem and i would be glad to receive some help.
If I create a stored procedure like this:
CREATE PROCEDURE [dbo].[Telerik] (@ID INT)
AS
BEGIN
 
IF(OBJECT_ID('tempdb..#tmp') IS NOT NULL)
BEGIN
    DROP TABLE #tmp
END
 
CREATE TABLE #tmp
(
ID INT
)
 
INSERT INTO #tmp
    SELECT @ID
     
SELECT * FROM #tmp
 
END
GO
 
EXEC [dbo].[Telerik]  229

result will be quite obvious (it is just a sample to show You my problem).

Now, if I use this stored procedure as a data source command in Telerik Report Designer, it will of course show me the right result in window called "Preview Data Source Results"  but as soon as I click "Finish" button it will not display ANY columns in Data Explorer. Same story happens if I use table variable instead of tmp table. Question is, how can I get columns list in Data Explorer if I'm using tmp table or table variables in stored procedure ? Without it, it is a bit difficult to design anything, as every time I have to create procedure with simple select and proper column names, create data source command based on that procedure, and after that I am changing my procedure to "normal" code (column list in data explorer does not change in this situation). 

How can i avoid this ?

All the best,
Mateusz

2 Answers, 1 is accepted

Sort by
0
Accepted
Hadib Ahmabi
Top achievements
Rank 1
answered on 10 Apr 2013, 10:07 AM
0
Mateusz
Top achievements
Rank 1
answered on 15 Apr 2013, 08:45 AM
Hi :)

I would like to thank You for your help - after reading linked topic, problem can be marked as solved.

All the best,
Mateusz
Tags
Report Designer (standalone)
Asked by
Mateusz
Top achievements
Rank 1
Answers by
Hadib Ahmabi
Top achievements
Rank 1
Mateusz
Top achievements
Rank 1
Share this question
or