declare @t table(code varchar(20)) insert into @t select 'MN' insert into @t select 'MNN' insert into @t select 'MSN' insert into @t select 'MNS' insert into @t select 'M))))N' insert into @t select ',MasdfasdfN'select * from @t where code like 'M%N'
--查询所有字段?还是从所有字段里查询呢? select a.name as 表名,b.name as 字段名 from sysobjects a left join syscolumns b on a.id = b.id where a.xtype = 'u' and b.name like 'M%N'
select b.name 字段名 from sysobjects a ,syscolumns b where a.id=b.id and a.xtype = 'u' and b.name like 'M%N'
colname like 'M%N' 問個題外話: right(colname , 1) = 'N' and colname like 'M%' 執行的效果相同嗎 ? 效率也一樣嗎?
insert into @t select 'MN'
insert into @t select 'MNN'
insert into @t select 'MSN'
insert into @t select 'MNS'
insert into @t select 'M))))N'
insert into @t select ',MasdfasdfN'select * from @t where code like 'M%N'
select a.name as 表名,b.name as 字段名
from sysobjects a left join syscolumns b on a.id = b.id
where a.xtype = 'u' and b.name like 'M%N'
from sysobjects a ,syscolumns b
where a.id=b.id and a.xtype = 'u' and b.name like 'M%N'
colname like 'M%N'
問個題外話:
right(colname , 1) = 'N' and colname like 'M%'
執行的效果相同嗎 ? 效率也一樣嗎?