Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Syntax qustion when creating TEMP table on the fly
Message
De
17/04/2003 08:46:25
 
 
À
16/04/2003 11:37:39
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
00778391
Message ID:
00778781
Vues:
14
What are the actual problems that you're trying to solve?

-Mike

>Two questions...
>
>1) In a stored proc, I'm trying to execute a simple query 'on the fly' and stuff the results in a temp table.
>
>I've seen code posted on this forum that does the following...
>
>**************************
>Declare @lcSql VarChar(1000)
>CREATE TABLE #returnvalue ( cReturn VarChar(1000) )
>Set @lcSql = 'Select cField From Table where ' + @tcWhere
>INSERT INTO #returnvalue Exec (@lcSql)
>*****************************
>
>Here's my problem...in this example, the SELECT statement was pulling back a static/fixed set of columns. I will be bringing back multiple columns in my 'dynamic SELECT' statement, and I don't know what the columns are until runtime. [The SELECT field list is coming from a function]. So doing a CREATE statement on one field doesn't work for me.
>
>In partial T-SQL, partial FoxPro, here's what I'm trying to do...
>
>DECLARE @cSQLLine VARCHAR(1000)
>DECLARE @cSQLCmd VARCHAR(1000)
>@cSQLLine = GetFieldList('sometable') --- this is a stored proc that will
> return a comma delimited list
>@cSQLCmd = 'SELECT ' + cSQLLine + ' FROM INSERTED'
>INSERT INTO #TempTbl EXEC (@cSQLCmd)
>
>
>2) Related question...I know that UPDATE triggers have access to the INSERTED/DELETED tables. [It seems that INSERTED/DELETED are only visible inside a trigger] I'd like for an external stored proc to have access to these. The only way I know is to do the following...
>
>SELECT * INTO #TEMPINSERTED FROM INSERTED
>
>...and then my stored proc will have access to it. Is there any other way for a trigger to 'pass' the INSERTED/DELETED system tables to a stored proc?
>
>Thanks a million to whomever can help me solve this puzzle!
>Kevin
Michael Levy
MCSD, MCDBA
ma_levy@hotmail.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform