22,181
社区成员




select * from viewname where colname='adfadf'
create index IX_Col on viewname (colname)
[Quote=引用 2 楼 libin_ftsafe 的回复:]
1、一定是你写错了
2、在动态SQL执行之间,先把临时表创建好,在执行完动态SQL之后,临时表就仍然可用,如:…
[/Quote]
我没有定义临时表,直接 是这种格式的
如果存在先删除
然后是动态的下面这些:
exec('SELLECT * INTO #TEMP FROM 视图')
恩 刚看了下 有问题
第一种写法
declare @str varchar(100)
set @str='adfadf'
select * from viewname where colname=@str
第二种写法
select * from viewname where colname='adfadf'
第一种写法花的时间基本上是第二种的九倍
create table #(id int,code varchar(10))
exec('insert into # select 1,''a''' union select 2,''b'')
select * from #
--这样有问题吗?
declare @str varchar(100)
set @str='adfadf'
select * from viewname where colname=@str