最近自己做了个小项目,涉及到了大量的正则表达式匹配和处理,在这里也和大家分享一下. 我相信接触过SQL Server数据库的很多朋友都知道,它是以"--"开头来进行注释的,但你觉得匹配它真的很容易吗? 让我们来看一些例子: --获取表的count信息 select count(*) from T with(nolock) --获取特定值的count信息 select count(*) from T with(nolock) where v = '--value' --获取表'T'的co
1.查询注释 SELECT A.name AS table_name, B.name AS column_name, C.value AS column_description FROM sys.tables A INNER JOIN sys.columns B ON B.object_id = A.object_id LEFT JOIN sys.extended_properties C ON C.major_id = B.object_id AND C.minor_id = B.column
对表中数据分组,有时只需要某列的聚合值:有时却需要返回整行数据,常用的方法有:子查询.ROW_NUMBER.APPLY,总体感觉还是ROW_NUMBER比较直观.测试数据: if OBJECT_ID('testGroup') is not null drop table testGroup GO create table testGroup ( ID int identity primary key, UserID int, OrderID int ) GO insert testGroup ,
取SQL分组中的某几行数据 对表中数据分组,有时只需要某列的聚合值:有时却需要返回整行数据,常用的方法有:子查询.ROW_NUMBER.APPLY,总体感觉还是ROW_NUMBER比较直观.测试数据: if OBJECT_ID('testGroup') is not null drop table testGroup GO create table testGroup ( ID int identity primary key, UserID int, OrderID int ) GO inse
常用的方法有:子查询.ROW_NUMBER.APPLY,总体感觉还是ROW_NUMBER比较直观 if OBJECT_ID('testGroup') is not null drop table testGroup GO create table testGroup ( ID int identity primary key, UserID int, OrderID int ) GO insert testGroup , union all , union all , union all , u