0
A script - row number
Participant
,
/t5/coldfusion-discussions/a-script-row-number/td-p/779529
Mar 18, 2009
Mar 18, 2009
Copy link to clipboard
Copied
I need a cf script that finds out the total row count of a
sql database...Any idea?
The reason I need is to compare our current db (on SQL05) with the new one that will be attached to the SQL 05....
The reason I need is to compare our current db (on SQL05) with the new one that will be attached to the SQL 05....
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/a-script-row-number/m-p/779530#M72383
Mar 18, 2009
Mar 18, 2009
Copy link to clipboard
Copied
I don't know about a CF script, but a pretty damn simple SQL
script is:
SELECT count(*)
FROM aTable
SELECT count(*)
FROM aTable
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
emmim44
AUTHOR
Participant
,
LATEST
/t5/coldfusion-discussions/a-script-row-number/m-p/779531#M72384
Mar 18, 2009
Mar 18, 2009
Copy link to clipboard
Copied
I have found a stored procedure that does what I need...
thank you all
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[listTableRowCounts]
AS
BEGIN
SET NOCOUNT ON
DECLARE @SQL VARCHAR(255)
SET @SQL = 'DBCC UPDATEUSAGE (' + DB_NAME() + ')'
EXEC(@SQL)
CREATE TABLE #foo
(
tablename VARCHAR(255),
rc INT
)
INSERT #foo
EXEC sp_msForEachTable
'SELECT PARSENAME(''?'', 1),
COUNT(*) FROM ?'
SELECT tablename, rc
FROM #foo
ORDER BY tablename,rc ASC
DROP TABLE #foo
END
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[listTableRowCounts]
AS
BEGIN
SET NOCOUNT ON
DECLARE @SQL VARCHAR(255)
SET @SQL = 'DBCC UPDATEUSAGE (' + DB_NAME() + ')'
EXEC(@SQL)
CREATE TABLE #foo
(
tablename VARCHAR(255),
rc INT
)
INSERT #foo
EXEC sp_msForEachTable
'SELECT PARSENAME(''?'', 1),
COUNT(*) FROM ?'
SELECT tablename, rc
FROM #foo
ORDER BY tablename,rc ASC
DROP TABLE #foo
END
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

