If you use temp tables, you'd have to populate the fields list manually. Use
table variables if you can. If you use table variables in your stored
procedures, the fields list is automatically populated for you. Here's a
simple example of how to use a table variable in your stored procedures:
++++++++++++++++++++++++++
create proc temptablevar AS
begin
declare @testtable table (title varchar(256), type varchar(256), price
decimal)
insert into @testtable select title, type, price from titles
select * from @testtable
end
++++++++++++++++++++++++++
On your second question, there are two types of temp tables in SQL Server:
Global and Local. If you create a **local** temp table (i.e., if the name of
the temp table is prefixed with one pound sign "#"), it is always local in
scope, i.e., other users don't see it. On the other hand, if you use a
**global** temp table (i.e., if the name of the temp table is prefixed with
two pound signs), it is global in scope (visible across all sessions.)
Check
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_ta-tz_7ysl.asp?frame=true
and
http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B305977 for
information on table variables. Check
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_create2_8g9x.asp?frame=true
for details on local and global temp tables.
--
Ravi Mumulla (Microsoft)
SQL Server Reporting Services
This posting is provided "AS IS" with no warranties, and confers no rights.
[quoted text, click to view] "James Foye" <jimfoye2@hotmail.com> wrote in message
news:uH4WMTWfEHA.396@TK2MSFTNGP12.phx.gbl...
> Thanks. Can Reporting Services see a table in tempdb? If so, how would I
> link fields in the source to fields in the report in the designer? In
> Access, I would actually create the table in the mdb, and the Access
report
> designer can of course see it. I'm not sure how this would work in
Reporting
> Services.
>
> The other thing I wasn't sure about with respect to temporary tables is
that
> in Access, each user is using the temp table on his local HD, so I'm not
> concerned about disk space issues. On the server, if I have a lot of users
> doing a report that uses a temp table, then tempdb is filling up, and of
> course this potentially impacts other users who are simply doing sorts or
> something.
>
> Jim
>
> "Scott Allen" <bitmask@[nospam].fred.net> wrote in message
> news:s47ah0h23o8bq2jat4rqsha9hklcs5d5df@4ax.com...
> > Hi James:
> >
> > With SQL Server prefix the table name with a single '#' character.
> > This gives you a 'local temporary table'. Local temp tables are only
> > visible to the current connection. You could have 5 users on 5
> > connections executing the same query which puts temporary results into
> > a table named #FooBar, and each one will see a distinct table - they
> > won't interfere.
> >
> > HTH,
> >
> > --
> > Scott
> >
http://www.OdeToCode.com > >
> > On Sat, 7 Aug 2004 10:48:23 -0500, "James Foye" <jimfoye2@hotmail.com>
> > wrote:
> >
> > >I installed Reporting Services and looked it for a bit and got very
> excited.
> > >I love the architecture (separating the file format from the designer
and
> > >renderers). I even called a couple of customers and talked it up.
> > >
> > >After my initial enthusiasm died down I pondered something. Sometimes
> when I
> > >do a complex report in Access, I have to build a temporary table and
fill
> > >it. I try to avoid that, but sometimes it's necessary. In Access, this
is
> no
> > >problem, because I always have the database split and the each user has
> his
> > >own copy of the front-end mdb on a local drive. So he can run a report
> and
> > >populate a temporary table without stepping on anyone else.
> > >
> > >How would I accomplish the same thing when using Reporting Services?
> > >
> > >Jim
> > >
> >
>
>