Posted by Helmut Woess on 09/07/06 08:05
Am 6 Sep 2006 22:14:18 -0700 schrieb pukivruki@gmail.com:
> hi,
>
> I wish to create a temporary table who's name is dynamic based on the
> argument.
>
> ALTER PROCEDURE [dbo].[generateTicketTable]
>
> @PID1 VARCHAR(50),
> @PID2 VARCHAR(50),
> @TICKET VARCHAR(20)
> AS
> BEGIN
>
> SET NOCOUNT ON;
>
> DECLARE @DATA XML
>
> SET @DATA = (SELECT dbo.getHistoryLocationXMLF (@PID1, @PID2) as data)
> CREATE TABLE ##@TICKET (DATA XML)
>
> INSERT INTO ##@TICKET VALUES(@DATA)
>
> END
>
>
> is what i have so far - although it just creates a table with a name of
> ##@TICKET - which isn't what i want. I want it to evaluate the name.
>
> any ideas?
Use EXECUTE for the create statement:
....
EXEC('CREATE TABLE ##' + @TICKET + ' (DATA XML)')
....
bye, Helmut
[Back to original message]
|