Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
OpenRowSet() and parameterization
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Divers
Thread ID:
01681195
Message ID:
01681218
Vues:
36
>Hmm,
>
>1) global temporary table
>
>CREATE OR ALTER PROCEDURE dbo._mishap_sp(@lcTMP NVARCHAR(128))
>AS
> DECLARE @lcSQL NVARCHAR(4000)
> SELECT @lcSQL=REPLACE(N'SELECT * INTO ##%TMP% FROM [INFORMATION_SCHEMA].[TABLES]', '%TMP%', @lcTMP)
> EXEC sp_executesql @lcSQL
> --SELECT * FROM #temp
>GO
>
>EXEC dbo._mishap_sp 'mytmp'
>select * from  ##mytmp
>drop table ##mytmp
>GO
>
>
>2) cursor parameter
>
>DECLARE @lorsData CURSOR, @lcSQL NVARCHAR(MAX)
>
>    SET @lcSQL='SET @loCursor = CURSOR LOCAL READ_ONLY FOR 
>      SELECT *
>        FROM '+@lcTABLENAME+' AA INNER JOIN #OBJECTs  AB ON AA.DATABASEID=AB.DATABASEID AND AA.OBJECTID=AB.OBJECTID AND ....
>        WHERE AA.EVENTCLASS=44
>        ORDER BY AA.EVENTSEQUENCE
>        ;
>       OPEN @loCursor'
> END
>
> EXEC sp_executesql @lcSQL, N'@loCursor CURSOR OUTPUT', @lorsData OUTPUT
>
> WHILE 0 = 0 BEGIN
>   FETCH NEXT FROM @lorsData INTO @liEVENTSEQUENCE, ...
>   IF @@FETCH_STATUS <> 0 BREAK
>
>
>END
> CLOSE @lorsData
> DEALLOCATE @lorsData
>
>
Thanks, option 1 works.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform