Reply to Re: Creating a dynamic Global Temp Table within a stored procedure

Your name:

Reply:


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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация