Some useful instructions of SQL

xiaoxiao2021-03-06  27

Truncate the log of TEST and shrink the physical file to 1MB

Use test

Backup Log Test with truncate_only

Go

DBCC ShrinkFile (ERP_LOG, 1, TRUNCATEONLY)

Go

What is the system file of the current database?

Use test

SELECT * from Sysfiles

Query SQL Server system data

SELECT

Object_name (constid) 'connectiont name',

Constid 'construint id',

(Status & 0xF)

From sysconstraints

WHERE (status & 0xf) = 2

(Status & 0xF)

1 check PK

2 check Unique

3 check fk

4 check Check

5 check Default

Query all table names, field name

Select T.Name as Tablename, C.Name As ColName, St.Name As Coltype, C.Length

From dbo.sysObjects t

Left join dbo.syscolumns c on t.id = C.ID

Left join dbo.systypes st on c.xtype = st.xUsertype

Where t.xtype = 'u'

Order by t.name, c.colid

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

New Post(0)