Get the number of records (SQL Server) in the current database

zhaozj2021-02-16  70

Get the number of records in the current database:

IF

?

exists

(

SELECT

?

*

?

From

? DBO.SYSOBJECTS?

WHERE

? id?

=

?

Object_id

(N

'

[DBO]. [GetRecordcountsForaLTables]]

'

)?

and

?

ObjectProperty

(ID,? n

'

ISPROCEDURE

'

)?

=

?

1

)

Drop

?

Procedure

?

[

DBO

]

.

[

GetRecordcountsForAllTables

]

Go

Set

? Quoted_identifier?

Off

?

Go

Set

? ANSI_NULLS?

Off

?

Go

Create

??

Procedure

? DBO.GETRECORDCOUNTSFORALLTABLES?

AS

SELECT

??

'

Owner

'

=

Convert

(

charr

(

10

), t.table_schema, ??????

'

TABLE? NAME

'

=

Convert

(

charr

(

25

), t.table_name), ??????

'

RECORD? Count

'

=

Max

(I.ROWS)

From

? sysindexes? i,? information_schema.tables? t

WHERE

? T. TABLE_NAME?

=

?

Object_name

(I.ID) ??????

and

? T. TABLE_TYPE?

=

?

'

Base? Table

'

group

?

BY

? t.table_schema,? T.TABLE_NAME

Go

Set

? Quoted_identifier?

Off

Go

Set

? ANSI_NULLS?

On

Go

转载请注明原文地址:https://www.9cbs.com/read-14710.html

New Post(0)