Thanks that works a treat :)

Just needed to change the bigint to int for SQL7

Thank you very much 
James

-----Original Message-----
From: Axapta-Knowledge-Village@yahoogroups.com
[mailto:[EMAIL PROTECTED] On Behalf Of cdlmalherbe01
Sent: 04 August 2005 20:34
To: Axapta-Knowledge-Village@yahoogroups.com
Subject: [Axapta-Knowledge-Village] Re: SQL script to do record count


Hi James,

The following is crude and inefficient, but does the job.

create table ##TableRecordCount
        (TableName varchar(256) not null,
        RecordCount bigint not null)
declare @TableName varchar(256)
declare @SqlString nvarchar(4000)

declare Tables cursor read_only
for select [name] from sysobjects where [xtype] in ('U')

open Tables

fetch next from
        Tables
into
        @TableName

while @@fetch_status <> -1
        begin
                if @@fetch_status <> -2
                        begin
                                set @SqlString = 'insert into 
##TableRecordCount select ' + '''' + ltrim(rtrim(@TableName)) + '''' 
+ ',count(*) from ' + @TableName
                                exec sp_executesql @SqlString
                        end

                fetch next from
                        Tables
                into
                        @TableName

        end 

select * from ##TableRecordCount

close Tables
deallocate Tables
drop table ##TableRecordCount

Hope it helps!

Christoph

--- In Axapta-Knowledge-Village@yahoogroups.com, "James Flavell" 
<[EMAIL PROTECTED]> wrote:
> Hi
>  
> Does anyone have a SQL script that I can run against a Axapta DB
to get a
> simple output of table name and record count for the table?
>  
> I need to do a check of record counts from a SQL 7 to SQL 2000
upgrade to be
> sure everything is in order after the upgrade.
>  
> Thank you very much
> James





Sharing the knowledge on Axapta. 
Yahoo! Groups Links



 





------------------------ Yahoo! Groups Sponsor --------------------~--> 
<font face=arial size=-1><a 
href="http://us.ard.yahoo.com/SIG=12htkkv8q/M=362131.6882500.7825259.1493532/D=groups/S=1705001380:TM/Y=YAHOO/EXP=1123210863/A=2889190/R=0/SIG=10r90krvo/*http://www.thebeehive.org
">Put more honey in your pocket. (money matters made easy) Welcome to the Sweet 
Life - brought to you by One Economy</a>.</font>
--------------------------------------------------------------------~-> 

Sharing the knowledge on Axapta. 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/Axapta-Knowledge-Village/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to