--SQL查询每个表的字段数量select b.[name], count(*) As AllCount,ISNULL(ISNULL(sum(case when isnullable=0 then 1 end),null),null) as NotNullCountfrom syscolumns aINNER JOIN( select [id], [name] from [sysobjects] where [type] = 'u' ) AS b ON a.id = b.[id] GROUP b…
SQL查询一个表中类别字段中Max()最大值对应的记录 SELECT A.id, A.name, A.version FROM DOC A, (SELECT id, MAX(version) AS version FROM DOC GROUP BY id) AS B WHERE A.id = B.id AND A.version = B.version…
一般都是写的单表update语句,很少写多表关联的update,但是事实上,在SQL Server中,update的多表连接更新和select的多表连接查询在使用的方法上其实并没有多大区别. 直接上一个例子就好了. update aaa set aaa.name = bbb.name from user_01 aaa left join user_02 bbb on aaa.code = bbb.code where bbb.name is not null; 和select语句基本上差不多的,…