查询数据库中某个特定的字段所在的所以表(不包含视图)
--查询数据库中某个特定的字段所在的所以表(不包含视图)
select a.[name] 表名 from sysobjects a
left join(select [id],count(*) b from syscolumns where [name]
in('Id','SellerNick') group by [id] having count(*)>1
) b on a.[id]=b.[id]
where b.id is not null and a.type<>'V'
--创建虚拟表,把值带给他
declare @tb table(NewSellerNick nvarchar(20),SellerNick nvarchar(20))
insert @tb
select '演示店铺'+CAST(id as nvarchar(10)),SellerNick from T_ERP_Shop
----查询数据库中某个特定的字段所在的所以表(不包含视图)并修改这些表的指定字段的内容
select 'update '+ a.[name]+' set SellerNick=t.NewSellerNick from @tb t where t.SellerNick='+ a.[name]+'.SellerNick' 表名 from sysobjects a
left join(select [id],count(*) b from syscolumns where [name]
in('Id','SellerNick') group by [id] having count(*)>1
) b on a.[id]=b.[id]
where b.id is not null and a.type<>'V'
浙公网安备 33010602011771号