Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Attempt at a general counting SP
Message
 
À
26/02/2003 12:25:27
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
00758191
Message ID:
00758272
Vues:
25
Bob,

Thanks for the reply. I've decided that segmenting this operation out has defeated the purpose of simplifying my stored procs.

Doug

>>I'm trying to create a SP that can return a count of rows for a specified table, column and column value. I get an error that states "Must declare the variable @tcTable".
>>
>>Any ideas?
>
>Try something like this:
>
>
>CREATE PROCEDURE get_count
>(@tcTable  varchar(30)
>,@tcColumn varchar(30)
>,@tnValue  integer
>
>AS
>
>CREATE TABLE #getcount
>(countis     int)
>
>EXEC (
>'DELCARE @nCount integer
>SELECT @nCount = count(*) FROM '+@cTable+' WHERE '+@tcColumn+' = '+@tnValue
>'INSERT #getcount (countis) VALUES (@nCount)'
>)
>
>declare @nCount integer
>
>select @nCount = countis from #getcount
>
>RETURN @nCount
>GO
>
>
>
>BOb
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform