[sql server]
select name,case when xtype='u' then 'usertable' else 'userview' end as xtype
from sysobjects
where id in (
select id from syscolumns where name in('商品编号','商品名称')
) and (xtype='u' or xtype='v')
order by xtype
select name,case when xtype='u' then 'usertable' else 'userview' end as xtype
from sysobjects
where id in (
select id from syscolumns where name in('商品编号','商品名称')
) and (xtype='u' or xtype='v')
order by xtype
本文介绍了一个SQL Server中的实用查询案例,通过使用CASE WHEN语句结合sysobjects和syscolumns视图来筛选特定类型的数据表和视图。具体展示了如何根据字段名称筛选对应的表或视图,并按类型进行排序。
1052

被折叠的 条评论
为什么被折叠?



