Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Dynamically naming local temp tables
Message
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Title:
Dynamically naming local temp tables
Miscellaneous
Thread ID:
00961561
Message ID:
00961561
Views:
44
To all,

I'm writing a series of stored procedures in SQL Server 2000. My intent is for the procedures to create one or more local temp tables. The tables' name will be dynamically created and the dynamically created table name will be passed back through an output parameter.

Issue one: What's the best way to create a unique string to be used as a temp table name?

Issue two: How can I get SQL Server to accept the temp table name in a query?

For example:

DECLARE @cMyTempTable VarChar(25)
SET @cMyTempTable = [unique string]

SELECT *
INTO #@cMyTempTable
FROM dbo.MySourceTable

When I try this, SQL Server gets very unhappy with the INTO clause.

All of this is well established methodology in FoxPro, my milk language, but I can't find any indication of how to do this with SQL Server.

Any help?

TIA

Thom C.
Next
Reply
Map
View

Click here to load this message in the networking platform