1 ;with cte as 2 ( 3 select * from Associator where No = 'mc1007' 4 union all 5 select air.* from Associator as air inner join cte on air.ParentNo = cte.No 6 ) 7 select * from cte;
--1.向已有表中增加一列 ALTER TABLE TableName ADD ColumnName VARCHAR(20) NULL --2.删除表中的某一列 ALTER TABLE TableName DROP COLUMN ColumnName --3.修改某一列的数据类型 ALTER TABLE TableName ALTER COLUMN ColumnName INT 2.查询当年或者当月的数据 1.查询当年的数据 SELECT * FROM UserInfo WHERE YEAR(R
SQL Server 查询锁表 select request_session_id spid,OBJECT_NAME(resource_associated_entity_id) as tableName ,* from sys.dm_tran_locks where resource_type='OBJECT' and OBJECT_NAME(resource_associated_entity_id) is not null SQL Server 解锁表 declare @spid int
原文:sql server 查询数据库所有的表名+字段 SELECT * FROM INFORMATION_SCHEMA.columns WHERE TABLE_NAME='Account' SELECT (case when a.colorder=1 then d.name else '' end) as 表名,--如果表名相同就返回空 a.colorder as 字段序号, a.name as 字段名, (case when COLUMNPROPER
原文:sql server 查询某个表被哪些存储过程调用 sql server 查询某个表被哪些存储过程调用 select distinct object_name(id) from syscomments where id in (select id from sysobjects where type ='P') and text like'%TableName%' 原文地址:https://www.cnblogs.com/lonelyxmas/p/9491635.html