Sql Server工作日常使用sql--持续完善中

select STUFF('232',1,1,'')结果为32,从第一个字符开始去掉一个字符,及去掉


select CONCAT('-','asd')结果为-asd,连接两个字符串


select concat('-',DataPointId) from [OperationData].[dbo].[DataLens_DataPoint] for xml path('')表示把 [OperationData].[dbo].[DataLens_DataPoint]

表中的DataPointId以-34-34-34的方式连接成一个字符串.

sp_spaceused'SecuritySearch'--查找某个表里边有多少条记录
dbccshow_statistics('SecuritySearch','IX_Status_Universe_CUSIP')--查找某个表里边某个字段的值有多少条记录.
 
 
查看表存在哪些索引
SELECT   a.name,c.name,d.name
FROM   sysindexes   a  
JOIN   sysindexkeys   b   ON   a.id=b.id   AND   a.indid=b.indid  
JOIN   sysobjects   c   ON   b.id=c.id  
JOIN   syscolumns   d   ON   b.id=d.id   AND   b.colid=d.colid  
WHERE   a.indid   NOT IN(0,255)  
-- and   c.xtype='U'   and   c.status>0 --查所有用户表  
AND   c.name='BatchUploadDataRecords' --查指定表  
ORDER BY   c.name,a.name,d.name ;
原文地址:https://www.cnblogs.com/cby-love/p/5652014.html