Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Cannot pass the File Name
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
00421483
Message ID:
00421804
Vues:
16
This won't work. When you use dynamic SQL, SQL Server considers it a seperate batch. It's not optimized when the compiler hits it and it has no access to variables outside of it

If you want to make it work, you'll have to write the results to a temporary table and then read it from there.


CREATE PROCEDURE GetRecordCount
@Tablename varchar(30),
@NumRecs integer OUTPUT
AS
CREATE TABLE #cnt (cnt integer)
EXECUTE (INSERT INTO #cnt VALUES (SELECT COUNT(*) FROM '+@TableName+' WHERE include = ''Y'' ')
SELECT @NumRecs = cnt FROM #cnt
RETURN 0

Or something like that <s>


-Mike
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