Showing posts with label batch. Show all posts
Showing posts with label batch. Show all posts

Wednesday, March 21, 2012

Script that Return the number of Rows for each Table on a DB

I Have 2 separate data bases with the same Tables and records, I create
a batch to synchronize my data every 2 hours but now I need a Script
that Return the number of Rows for each Table on each DB.
Can someone give me an Idea or the solution for this, I will really
appreciate it.This is what the code I have, now I need to insert the total rows per
table
IF OBJECT_ID('tempdb..#TableSummary') IS NOT NULL
DROP TABLE #TableSummary
SELECT DISTINCT TABLE_NAME AS TableName, 0 as CountOfTable
INTO #TableSummary
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME IN
(SELECT TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE (TABLE_TYPE = 'BASE TABLE' AND
TABLE_NAME NOT IN ('dtproperties','TableSummary','AllUserT
ables')))
SELECT * FROM #TableSummary|||This is what I have, now I need to insert the total rows per
table
IF OBJECT_ID('tempdb..#TableSummary') IS NOT NULL
DROP TABLE #TableSummary
SELECT DISTINCT TABLE_NAME AS TableName, 0 as CountOfTable
INTO #TableSummary
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME IN
(SELECT TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE (TABLE_TYPE = 'BASE TABLE' AND
TABLE_NAME NOT IN
('dtproperties','TableSummary','AllUserT
ables')))
SELECT * FROM #TableSummary|||Run this query against each database:
SELECT DISTINCT TOP 100 PERCENT dbo.sysobjects.name, dbo.sysindexes.rowcnt
FROM dbo.sysobjects INNER JOIN
dbo.sysindexes ON dbo.sysobjects.id = dbo.sysindexes.id
WHERE (dbo.sysobjects.xtype = 'U') AND (dbo.sysindexes.status = 0)
ORDER BY dbo.sysobjects.name
"imagabo" wrote:

> I Have 2 separate data bases with the same Tables and records, I create
> a batch to synchronize my data every 2 hours but now I need a Script
> that Return the number of Rows for each Table on each DB.
> Can someone give me an Idea or the solution for this, I will really
> appreciate it.
>|||This is it, Thank you so much bschaettle, I own you one.

Saturday, February 25, 2012

SCREWY LAST BATCH DATE

Using SQL2k EE SP3
There's a spid in the activity monitor that has a Last Batch date of
1/1/1900 12:00AM however, the logged In date is recent. What could cause
this to happen?
tia
MG
MG,
Perhaps because it has logged in, but never executed a batch. 1/1/1900
12:00 AM is datetime 0, since last_batch is a non-nullable column.
I have seen this with some applications where 1 connnection will display
this behavior as other connections do the actual work.
RLF
"Hurme" <michael.geles@.thomson.com> wrote in message
news:5EEF3B0D-CA4D-43C8-84DB-88AA8614241A@.microsoft.com...
> Using SQL2k EE SP3
> There's a spid in the activity monitor that has a Last Batch date of
> 1/1/1900 12:00AM however, the logged In date is recent. What could cause
> this to happen?
> tia
> --
> MG

SCREWY LAST BATCH DATE

Using SQL2k EE SP3
There's a spid in the activity monitor that has a Last Batch date of
1/1/1900 12:00AM however, the logged In date is recent. What could cause
this to happen?
tia
--
MGMG,
Perhaps because it has logged in, but never executed a batch. 1/1/1900
12:00 AM is datetime 0, since last_batch is a non-nullable column.
I have seen this with some applications where 1 connnection will display
this behavior as other connections do the actual work.
RLF
"Hurme" <michael.geles@.thomson.com> wrote in message
news:5EEF3B0D-CA4D-43C8-84DB-88AA8614241A@.microsoft.com...
> Using SQL2k EE SP3
> There's a spid in the activity monitor that has a Last Batch date of
> 1/1/1900 12:00AM however, the logged In date is recent. What could cause
> this to happen?
> tia
> --
> MG