exec('select * from '+@Name)substring('200301',1,4)
1 exec('select * from '+@name) 2 exec('select * from '+@name+'where substring('200301',1,4)='2003'')
我不想用exec 怎么办?我一年12各表呀
declare @Name char(10) declare @s char(10) set @name='01200308' exec('select @s=Field1 from ' + @Name)如何返回@s 呀!不行把
select @Namesubstring('200301',1,4)
declare @Name char(10) declare @@s char(10) set @name='01200308' exec('select @@s=Field1 from ' + @Name)select @@s
我不想用exec 怎么办?我一年12各表呀 declare @Name char(10) declare @s char(10) set @name='01200308' exec('select @s=Field1 from ' + @Name)如何返回@s 呀!
exec('select Field1 into @@s from ' + @Name)select * from @@sdrop table @@s
1、declare @Name char(10) set @name='01200308' exec('select * from ['+@Name+']')
2、我的数据按月存储如:表‘200301’,‘200302’ 如何查询一年的数据?? 建立视图:create view [2003] as select * from [200301] union all select * from [200302] union all select * from [200303] union all select * from [200304] union all select * from [200305] union all select * from [200306] union all select * from [200307] union all select * from [200308] union all select * from [200309] union all select * from [200310] union all select * from [200311]
2 exec('select * from '+@name+'where substring('200301',1,4)='2003'')
怎么办?我一年12各表呀
declare @s char(10) set @name='01200308'
exec('select @s=Field1 from ' + @Name)如何返回@s 呀!不行把
declare @@s char(10) set @name='01200308'
exec('select @@s=Field1 from ' + @Name)select @@s
怎么办?我一年12各表呀
declare @Name char(10)
declare @s char(10) set @name='01200308'
exec('select @s=Field1 from ' + @Name)如何返回@s 呀!
set @name='01200308'
exec('select * from ['+@Name+']')
2、我的数据按月存储如:表‘200301’,‘200302’ 如何查询一年的数据??
建立视图:create view [2003]
as
select * from [200301]
union all
select * from [200302]
union all
select * from [200303]
union all
select * from [200304]
union all
select * from [200305]
union all
select * from [200306]
union all
select * from [200307]
union all
select * from [200308]
union all
select * from [200309]
union all
select * from [200310]
union all
select * from [200311]