Global Temporary Table Usage In Sub Reports

Mar 28, 2008



Hi,

I have a report that calls a stored procedure that creates an extract of data for use by various subreports. Now I have this problem:

If I save the extract data in a global temporary table, then it is automatically deleted before the subreports can use it, this means I have to create a normal table with a unique name that need to be deleted - but where do you do this in the report - there is no point where you can say it is now safe to delete a table?

I do not want to resort to external mechanisms, languages, jobs etc. to do this. I want to delete the table once the report is really finished in the report.

My main report uses a list that contains all the subreports as I need to group all sorts of information by vendor. The main report calls the stored procedure. Please do not tell me that I have to duplicate the main extract for every subreport. That will really eat resources.

Thanks in advance.

View 4 Replies


ADVERTISEMENT

Global Temporary Table Usage In Subreports

Mar 28, 2008



Hi,

I have a report that calls a stored procedure that creates an extract of data for use by various subreports. Now I have this problem:

If I save the extract data in a global temporary table, then it is automatically deleted before the subreports can use it, this means I have to create a normal table with a unique name that need to be deleted - but where do you do this in the report - there is no point where you can say it is now safe to delete a table?

I do not want to resort to external mechanisms, languages, jobs etc. to do this. I want to delete the table once the report is really finished in the report.

My main report uses a list that contains all the subreports as I need to group all sorts of information by vendor. The main report calls the stored procedure. Please do not tell me that I have to duplicate the main extract for every subreport. That will really eat resources.

Thanks in advance.

View 6 Replies View Related

Global Temporary Table

Dec 23, 2006

Hi,
what im trying to do is to combine multiple SELECT staetment so that it could produce 1 dataset instead of 2(multiple). (fields and column are same, just different tblname). Okay, so im thinking of insert those into temp table.

1. select statement 1 > insert into #MyTemp
2. select statement 2 > i want to insert into #MyTemp too...

Problem is sql disallowed this. That's why im thinking of global temporary table, but dunno how to write tht :P.
Pliz help. Thanks in advance

View 7 Replies View Related

Global Temporary Table And SP

Jul 23, 2005

Hello all,I'm using SS2K on W2K.Brieffing: Many months ago, I created a stored procedure only used by thosewith admin rights in SS. Now, someone else (without admin rights) has to runit. I gave him rigth to execute the SP but, at the second and moreexecution, he got a error message concerning a temp table already existing(see further).The SP:------------------------------------------------------CREATE PROCEDURE MySP@Type INTDECLARE @strSQL AS VARCHAR(4000)IF EXISTS (SELECT table_name FROM tempdb.information_Schema.tables WHEREtable_name = '##MyTmpTable')DROP TABLE ##MyTmpTableSELECT @strSQL = 'SELECT MyField1, MyField2, MyField3 INTO ##MyTmpTable FROMMyTable'EXECUTE(@strSQL)IF @Type = 1SELECT MyField1FROM ##MyTmpTableELSE IF @Type = 2SELECT MyField2FROM ##MyTmpTableELSESELECT MyField3FROM ##MyTmpTableGO------------------------------------------------------The error I got on the second time the user run the sp is: "Table##MyTmpTable already exists." The front-end where this SP is run is A97.That's where I got this message. This SP looks like a simple SELECT queryfrom A97 users perspective.Please, do no argue about the way of doing the work done! It is simplifiedat most in order to make it short and easy to read. I have to use thecommand "EXECUTE(String)" and, because of this, I connot use a localtemporary table instead of a global one.I suspect non-admin user cannot drop global temporary table, but the errormessage makes me believe that this code line is not even run, as if thecondition "IF EXISTS(...)" return false even if the table actualy exists.Anybody can help about this? What should I do to solve this problem?Yannick

View 2 Replies View Related

Accessing Global Temporary Table

Jan 29, 2001

We are trying to use a ## table (global temporary table) in Access or Excel thru a ODBC connection to tempdb. We are able to see the system tables, but not any ## tables. We are able to perform selects on the same ## table with the same userid and password in Query Analyzer. If we use sa or make the userid dbo we are able to see the ## tables, but I don't want to give these type of permissions.

Any help would be appreciated. Thanks in advance.

View 1 Replies View Related

SQL Server 2012 :: Creating And Dropping Global Temporary Table?

Apr 3, 2015

I want to create and drop the global temporary table in same statement.

I am using below command but I am getting below error

Msg 2714, Level 16, State 6, Line 11

There is already an object named '##Staging_Temp' in the database.

if object_id('Datastaging..##Staging_Temp') is not null
begin
drop table ##Staging_Temp
end
CREATE TABLE ##Staging_Temp(
[COL001] [varchar](4000) NULL,

[Code] ....

View 1 Replies View Related

Reference A Temporary ##global Table Of A Linked Server Using 4-parts Identifier

Oct 17, 2007

Is it possible to reference a temporary global tale (##table) of a linked server using the 4 parts "identifier": linkedserver.database.schema_name.##object_name ??
Thanks in advance for your help.

View 2 Replies View Related

Transact SQL :: Usage Of OUTPUT Clause Depending On Temporary Table

Jul 14, 2015

Suppose we have the following table in our database;

CREATE TABLE [dbo].[PERMISSION](
[ID] [int] IDENTITY(1,1) NOT NULL,
[USERID] [int] NOT NULL,
[STARTTIME] [smalldatetime] NOT NULL,
[ENDTIME] [smalldatetime] NOT NULL,
[REASON] [nvarchar](250) NULL,
[PERMISSIONTYPEID] [int] NOT NULL,

[code]....

This code works pretty well. But I don't want to do this with "select" since there is OUTPUT clause in T-SQL. So the CommandText property will be changed into this;

command.CommandText = @"insert PERMISSION
output INSERTED.ID, INSERTED.CREATETIME into @outID, @outCREATETIME
values(2, getdate(), getdate(), 'sdfg', 1, DEFAULT);";

well, not only this statement gives an error while executing; but also, no such usage defined in the

documentation of OUTPUT Clause. Actually the documentation tell us to use Temporary Tables for that. So I have to change CommandText into this;
command.CommandText = @"DECLARE @MyTableVar table(ID int, CREATETIME smalldatetime);
insert PERMISSION
output INSERTED.ID, INSERTED.CREATETIME into @MyTableVar

code]....

No temporary tables required; thus, no "type spesific" things required. This way is easier to create dynamic queries though. Only,the RETURNING INTO clause.So, I was wondering; why MS-SQL (T-SQL) forces users to "declare a temporary table (type specific)" and "execute select on the temporary table in order to assign values to output parameters" while using "the OUTPUT Clause". Comparing to the Oracle's sample I'm just using "the RETURNING INTO Clause in order to assign values to output parameters" and that's it; very easy and dynamic. To Summarize, Oracle's RETURNING INTO Clause is better than MS-SQL's OUTPUT Clause, but in fact they're doing the same job.

View 7 Replies View Related

Create Global Temporary Tables In SQL SERVER

Sep 6, 2006

I m trying to create a global temporary table whose data will be deleted after the end of the session..

the DDL in oracle is

CREATE GLOBAL TEMPORARY TABLE STUDENT
(

name CHAR(20),

) ON COMMIT DELETE ROWS ;

I want to know the corresponding DDL in SQL Server..

when i try the following

CREATE TABLE ##STUDENT
(

name CHAR(20),

)

the table gets deleted at the end of the session..help needed



View 4 Replies View Related

Reports Usage Frequency For All The Existing Reports On SSRS 2000

Mar 18, 2008

I have an already published application running several MS SQL Server 2000 Reporting Services report.
I need a way to find from either the reporting services log or the application server (IIS) logs or windows log
to know the frequency of each report being used.

Based on this info, the business needs to know which reports are being used and to what extend?
How can I acheive this?

I have already got the IIS logs and it did not give the required info.
I have looked into the Reporting Services logs but it does not provide the info either.

Any help is appreciated

View 2 Replies View Related

Reports Usage Frequency For All The Existing Reports On SSRS 2000

Mar 18, 2008

I have an already published application running several MS SQL Server 2000 Reporting Services report.
I need a way to find from either the reporting services log or the application server (IIS) logs or windows log
to know the frequency of each report being used.

Based on this info, the business needs to know which reports are being used and to what extend?
How can I acheive this?

I have already got the IIS logs and it did not give the required info.
I have looked into the Reporting Services logs but it does not provide the info either.

Any help is appreciated

View 1 Replies View Related

SQL Server 2012 :: Maximum Number Of Global Temporary Tables?

Dec 9, 2014

What is the maximum no.of global temporary tables can create in sql server

View 4 Replies View Related

Usage Of Global Variables Inside SQL Task

Mar 11, 2008

I've been looking around but haven't yet found the syntax for usage of global variables in an SQL Task.

I've set the global variable Id (see code below):

if (select field from table where id = @[User::id]) is null
select top 1 1 as response from table
else select top 1 0 as response from table

My objective with it is to set another global variable (@isNull). Supposably, when the selection returns null, I should set the variable to null, I did it by using the selections and mapping the response to that variable (is ther a better way to do so?).

When I try to execute this, it says the variable has not been defined.
Here is the error:

Error: Must declare the variable '@'.

I've also tryed it withou the brackets and the User:: thing in the beggining, (@id directly) and here is the response:

Error: Must declare the variable '@id'.

How should I access the global variables in the SQL code?
(BTW, I've checked the field in execution time and it is set to 23, the correct Id, so the block that preceedes this one is working properly)

Thanks,




View 6 Replies View Related

Create Global Variable And Use It In Different Reports

Mar 10, 2008

I have some reports in the same project.
Is it possible to create a global variable that will be used in the different reports?
Thanks in advance.

View 5 Replies View Related

Reports About The Reports Usage

Apr 18, 2007

Hi,



We just deployed a report solution and I would like to know when and how much each report is used. Is there a report for it ?



With regards,



Constantijn Enders

View 3 Replies View Related

Disk Usage Reports After Creating Centralized MDW

Aug 13, 2013

I am having a problem with the disk usage reports after creating a centralised MDW on SQL Server 2008, this is the report displayed when you drill down onto a specific database.

When I drill down on a database on the local server to the MDW database the disk usage report is shown correctly.

However, when I drill down onto another servers database I receive the following error: A data source instance has not been supplied for the data source 'DS_TraceEvents'.

View 1 Replies View Related

What Is The Difference Between: A Table Create Using Table Variable And Using # Temporary Table In Stored Procedure

Aug 29, 2007

which is more efficient...which takes less memory...how is the memory allocation done for both the types.

View 1 Replies View Related

Possible To Have Temporary Rows In A Non-temporary Table? Lifespan On Rows..

Mar 14, 2004

I have a table that includes the html-output of different parts of my pages. This table grows very big very fast, and rows older than 24 hours are useless.

My question is if it is possible to have temporary rows, whose are automatically deleted after these 24 hours? And then how to accomplish that?

View 2 Replies View Related

Table Names In Stored Procedures As String Variables And Temporary Table Question

Apr 10, 2008

How do I use table names stored in variables in stored procedures?




Code Snippetif (select count(*) from @tablename) = 0 or (select count(*) from @tablename) = 1000000





I receive the error 'must declare table variable '@tablename''

I've looked into table variables and they are not what I would require to accomplish what is needed.
After browsing through the forums I believe I need to use dynamic sql particuarly involving sp_executesql. However, I am pretty new at sql and do not really understand how to use this and receive an output parameter from it(msdn kind of confuses me too). I am tryin got receive an integer count of the records from a certain table which can change to anything depending on what the user requires.




Code Snippet

if exists(Select * from sysobjects where name = @temptablename)
drop table @temptablename




It does not like the 'drop table @temptablename' part here. This probably wouldn't be an issue if I could get temporary tables to work, however when I use temporary tables i get invalid object '#temptable'.

Heres what the stored procedure does.
I duplicate a table that is going to be modified by using 'select into temptable'
I add the records required using 'Insert into temptable(Columns) Select(Columns)f rom TableA'
then I truncate the original table that is being modified and insert the temporary table into the original.

Heres the actual SQL query that produces the temporary table error.




Code Snippet
Select * into #temptableabcd from TableA

Insert into #temptableabcd(ColumnA, ColumnB,Field_01, Field_02)
SELECT ColumnA, ColumnB, Sum(ABC_01) as 'Field_01', Sum(ABC_02) as 'Field_02',
FROM TableB
where ColumnB = 003860
Group By ColumnA, ColumnB

TRUNCATE TABLE TableA

Insert into TableA(ColumnA, ColumnB,Field_01, Field_02)
Select ColumnA, ColumnB, Sum(Field_01) as 'Field_01', Sum('Field_02) as 'Field_02',
From #temptableabcd
Group by ColumnA, ColumnB




The above coding produces

Msg 208, Level 16, State 0, Line 1

Invalid object name '#temptableabcd'.

Why does this seem to work when I use an actual table? With an actual table the SQL runs smoothly, however that creates the table names as a variable problem from above. Is there certain limitation with temporary tables in stored procedures? How would I get the temporary table to work in this case if possible?

Thanks for the help.


View 6 Replies View Related

Creating A Common Table Expression--temporary Table--using TSQL???

Jul 23, 2005

Using SQL against a DB2 table the 'with' key word is used todynamically create a temporary table with an SQL statement that isretained for the duration of that SQL statement.What is the equivalent to the SQL 'with' using TSQL? If there is notone, what is the TSQL solution to creating a temporary table that isassociated with an SQL statement? Examples would be appreciated.Thank you!!

View 11 Replies View Related

Is It Possible To Insert Data Into A Table From A Temporary Table That Is Inner Join?

Mar 10, 2008

Is it possible to insert data into a table from a temporary table that is inner join?
Can anyone share an example of a stored procedure that can do this?
Thanks,
xyz789

View 2 Replies View Related

Global Temp Table Vs. Permanent Table Use

Dec 17, 2004

I need to decide what is better to use: global temp table ( I can't use local one) or permanent table in SQL 2000 stored procedures. I extract data from linked server table and update several tables on our server.
Those procedures scheduled to run every 3 hours.

Another question: for some reasons when I used global temp table, I wasn't able to schedule multi steps with every step executing one of the stored procedures.I think global temp tables should be visible to other stored procedures, right?

Your suggestions?

View 1 Replies View Related

Difference In Creating Temporary Table By #table And ##table

Nov 29, 2006

Banti writes "IF i create temporary table by using #table and ##table then what is the difference. i found no difference.
pls reply.
first:
create table ##temp
(
name varchar(25),
roll int
)
insert into ##temp values('banti',1)
select * from ##temp
second:
create table #temp
(
name varchar(25),
roll int
)
insert into #temp values('banti',1)
select * from #temp

both works fine , then what is the difference
waiting for ur reply
Banti"

View 1 Replies View Related

Temporary Table Vs. Table Valued Function

Jun 6, 2006

I need to return a table of values calculated from other tables. I have about 10 reports which will use approx. 6 different table structures.

Would it be better performance wise to create a physical table in the database to update while calculating using an identity field to id the stored procedure call, return the data and delete the records. For Example:

StrVal1,Strval2,StrVal4,IntVal1,IntVal2,FloatVal1...

Or using a table-valued function to return a temp table as the result.

I just dont know which overhead is worst, creating a table per function call, or using a defined table then deleting the result set per sp call.

View 4 Replies View Related

Global Temp Table ....

Feb 24, 2005

Hi:

A regular permanent table is not an option:
Need to exec a procA which at the end also exec procB.

procA will insert to table A and also generate a intermidate result set to a ##A global table, it works fine at this point. However, when it exec the procB at the end of exec procA, the ##A global table is empty when entering procB.

The key is I want to pass a records set to the procB without using a tableTempB. Does a ## global table should be still alive until procB execution is done?

I also tried use table variable, but it does not look like to accept @tableA
as part of the procB's parameters.

Also tried function, but it could not support a #tempTable within it which will do a dynamic query insertion.

thanks
David

View 4 Replies View Related

Temporary Table

Feb 1, 2004

Hi

I am using SQL 2000 I have the following code. When saving it, I am getting an error:
There is already an object named '##tbl' in the database

This is although #tbl is dropped.
Is threrea way to avoid this error? the only work around I found was to create a string with the SQL command and call EXEC, but I don't like this solution as it prevents early compilation of the procedure.

declare @x int
set @x=1
IF @x=0
begin
create table #tbl (
abc int
)
drop table #tbl
end

IF @x=1
begin
create table #tbl (
abc int
)
drop table #tbl
end

Than you.

View 5 Replies View Related

Temporary Table

Nov 8, 2005

Hi

I have to create a temporary table for generating a report in VB.
Pls help how to check the temporary table name in database.
I want if exits than drop and create a new one.


thanks

asm

View 3 Replies View Related

Temporary Table

Apr 11, 2006

I have the following fields in table A:

GL_ID|GL_Name_VC| Amount |Period_TI|Year_SI|
===================================================
1000| Sales | -20,000.00 | 01 | 2005
===================================================
1000| Sales | -10,000.00 | 02 | 2005
===================================================
1001| Cost | 5,000.00 | 01 | 2005
===================================================
1001| Cost | 5,000.00 | 02 | 2005

the fields above have the following datatype:

Fields | Datatype
===================================
GL_ID | Integer
GL_Name_VC | Variable Character
Amount | Integer
Period_TI | TinyInteger
Year_SI | SmallInteger

The above database is running on Microsoft SQL Server 2000 and i would like to query
for a report that looks something as below:

Description | Period 01 | Period 02 | Year to Date
=========================================================
Sales | 20,000.00 | 10,000.00 | 30,000.00
Total Sales | 20,000.00 | 10,000.00 | 30,000.00

Cost | 5,000.00 | 5,000.00 | 10,000.00
Total Cost | 5,000.00 | 5,000.00 | 10,000.00
=========================================================
Profit | 15,000.00 | 5,000.00 | 20,000.00

The above report would list 4 columns, with the last column being a calculated field as a sum of
Period01 + Period02 Amount, sorted by GL_ID and group under a summation row called
Total Sales & Total Cost.There would be a net amount appearing as Profit (Total Sales-Total Cost).

Guys, hope someone out there can help me with the sql command for the above report?

View 2 Replies View Related

Temporary Table

Jun 20, 2007

How would someone set up a temporary table from a database in order to then run a query against it to get more accurate data??

View 11 Replies View Related

Temporary Table

Jul 29, 2007

Hi,

i have:

[first table]
user_id
user_name
user_password

[second table]
set
item
order

Since the second table is somehow only temporary table (having at the front ajax script), i need the third table to store user's ID and all the info from second table.

What would be the easiest way to do it, since the first table contains only one row per user and the second one 40 rows per user.

thank you for your thought!

View 2 Replies View Related

Temporary Table

Nov 27, 2007

Hi,

my code looks like this

Declare @Temp Table(id_customer int, id_product varchar(10))
Insert Into @Temp(id_customer, id_product) Values(12, 'ABC104')
Insert Into @Temp(id_customer, id_product) Values(12, 'ABC143')
Insert Into @Temp(id_customer, id_product) Values(12, 'ABC103')
Insert Into @Temp(id_customer, id_product) Values(13, 'ABC102')
Insert Into @Temp(id_customer, id_product) Values(14, 'ABC101')
Insert Into @Temp(id_customer, id_product) Values(15, 'AABC10')
Insert Into @Temp(id_customer, id_product) Values(15, 'AABC11')

select * from @Temp
Declare @results VarChar(100)
Select @results = IsNull(@results + '; ', '') + IsNull(id_product, '')
From @Temp
where id_customer = 12
Select @results as all_products


and when i run "Select @results as all_products" what shall i do to get id_customer along? if i do "select id_customer, @results as all_products" I get error in return :(

thank you

View 5 Replies View Related

Temporary Table

Feb 12, 2007

hi!

i used some temporary table in store procedure (sqlserver 2005)

our team have report software calisto .

the calisto use crystal and reports which use

this store procedure .

because of that,

we have list of many temporary table with the same name

#dbo.sug_name ... ,#dbo.sug_name ... ,......

in the system database .

what could be the reason for that and how can we drop it ?

Msg 3701, Level 11, State 5, Line 2

Cannot drop the table '#sug_name', because it does not exist or you do not have permission."

View 10 Replies View Related

Temporary Table Name

Jun 27, 2006

Hi all

Is it possible to name a table when a script runs with the date ie

select name, address

into test (date)

from company

where the (date) is will be todays date

Thanks



Richard

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved