Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Record count of each table
Message
De
17/07/2000 08:27:07
 
 
À
16/07/2000 20:05:32
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
00393064
Message ID:
00393176
Vues:
19
You can't directly parameterize the table name in a query. Try using Dynamic SQL.

EXECUTE ('select count(*) from ' + @dest_tabname)

-Mike

>Hi all,
>
>I need a procedure from which i will get all the record count of each table which is replicated.
>i made following procedure
>
>Create procedure udsp_count_records
>AS
>declare @dest_tabname sysname
>Declare record_count cursor
>For
>
>Select a.name
>From ors..sysobjects a
>Where a.xtype = "U" and
> a.replinfo = 32
>
>Open record_count
>Fetch Next From record_count into
> @dest_tabname
>
>While @@fetch_status = 0
>Begin
>set nocount on
>select @dest_tabname
>
>select count(*) from @dest_tabname
>
> Fetch Next From record_count
> Into @dest_tabname
>end
>close record_count
>deallocate record_count
>
>
>but i got an syntex error near @dest_tabname in the line
> select count(*) from @dest_tabname
>
>any body have any clue. or any other idea.
>
>Thanks,
>....ashish
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