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 |
santhi
Starting Member
2 Posts |
Posted - 2009-03-23 : 23:58:18
|
Hi,I have a report which contains several queries - one of which is a stored procedure which creates a Temp table in the database. This temp table is then used by the other queries. The issue is that when I run the report, the stored procedure does not create the temp table before the other queries start using it. In fact, I need to run the report, and then refresh it in order to get the report to pull in the correct data (1st run populates the temp table, refresh then allows the queries to use it.).Is there a way to force the execution of the stored procedure before the other queries run?...I don't want to create stored procedures for each query, because the intitial creation of the Temp table is quite slow (5seconds), and to do this for each data subset would be very resource intensive.Thankssanthi |
|
santhi
Starting Member
2 Posts |
Posted - 2009-03-24 : 01:48:40
|
the below is tipical structure of my stored procedure USE [CMS_PRD]GO/****** Object: StoredProcedure [dbo].[testBIDS] Script Date: 03/24/2009 16:47:04 ******/SET ANSI_NULLS OFFGOSET QUOTED_IDENTIFIER OFFGOALTER PROCEDURE [dbo].[testBIDS] @project_id varchar(10)='' AsSET REMOTE_PROC_TRANSACTIONS OFFSET XACT_ABORT OFFSET ANSI_NULLS ONSET ANSI_WARNINGS ON/* clean up */delete ssrs_test1/* build up query */DECLARE @SQL1 varchar(800)DECLARE @SQL_PID varchar(100)IF (@project_id <> '<All>' )BEGIN SELECT @SQL_PID= ' p.project_id = '+@project_idENDELSEBEGIN SELECT @SQL_PID= ' 1=1 'ENDSELECT @SQL1 = 'insert ssrs_test1 select project_id, project_name from project pwhere '+ @SQL_PID +' 'BEGIN PRINT 'SQL is '+ @SQL1 EXEC (@SQL1)END |
|
|
|
|
|