查看表是否存在 if exists(select 1 from sysobjects where id = OBJECT_ID('数据库名称.dbo.表明称')) drop table 为字段添加注释: EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'列说明' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=
查看SqlServer 数据库中各个表多少行 : SELECT A.NAME ,B.ROWS FROM sysobjects A JOIN sysindexes B ON A.id = B.id WHERE A.xtype = 'U' AND B.indid IN(0,1) ORDER BY B.ROWS DESC 数据库磁盘占用量: select name, CAST(convert(float,size) * (8192.0/1024.0)/1024 AS nvarchar)+'MB' AS
1,查看那个表死锁 select object_name(resource_associated_entity_id) as tableName, request_session_id as pid from sys.dm_tran_locks where resource_type = 'OBJECT' 2,结束死锁的进程 kill 70
可以尝试如下建议:1.可以使用默认的Log工具或者第三方的(比如:LiteSpeed)的工具.2.做Trace机制,下次出现问题可以溯源.3.一个简单的办法: --Step #1: USE DBName GO SELECT [Transaction ID], Operation, Context, AllocUnitName FROM fn_dblog(NULL, NULL) WHERE Operation = 'LOP_DELETE_ROWS' and AllocUnitName= 'dbo.
select c.name as [字段名],t.name as [字段类型] ,convert(bit,c.IsNullable) as [可否为空] ,convert(bit,case when exists(select 1 from sysobjects where xtype='PK' and parent_obj=c.id and name in ( select name from sysindexes where indid in( select indid from sysin
DECLARE @tableName NVARCHAR(MAX);SET @tableName = N'UserIntegralExchange'; --表名!!! SELECT CASE WHEN col.colorder = 1 THEN obj.name ELSE '' END AS 表名 , col.colorder AS 序号 , col.name AS 列名 , ISNULL(ep.[value], '') AS 列说明 , t.name AS 数据类型 , col.length
SELECT a.name , b.[rows]FROM dbo.sysobjects AS a LEFT JOIN sysindexes AS b ON a.id = b.idWHERE a.[type] = 'U' AND b.indid IN(0,1) AND [rows]!=0 还有更好的方法 exec sp_spaceused 'UserRecordDetails' ! 我被虐爆了 ,愤
SELECT o.name,o.object_id,c.name,c.column_id,c.collation_name FROM sys.columns c JOIN sys.objects o ON c.object_id = o.object_id WHERE o.object_id = OBJECT_ID('dbo.FileImportMapping') AND c.name = 'OriginalFileId'
1.1 简介 SQL Server 中,用户定义表类型是指用户所定义的表示表结构定义的类型.您可以使用用户定义表类型为存储过程或函数声明表值参数,或者声明您要在批处理中或在存储过程或函数的主体中使用的表变量. 若要创建用户定义表类型,请使用CREATE TYPE语句.为了确保用户定义表类型的数据满足特定要求,您可以对用户定义表类型创建唯一约束和主键. 1.2 使用例题 在创建用户定义表类型前先建立一个数据库表 USE [Contacting] GO SET ANSI_NULLS ON GO SE