Hi all,
create procedure dbo****nquery
as
begin
select tempkey = identity(6), empl_id into #temptable from empl
select #temptable.tempkey, #temptable.empl_id from #temptable
end
The above stored procedure is working..But when i tried the same with dynamic query as below it is not working properly ..why

..Some one plzz help me
create procedure dbo****nquery
as
begin
DECLARE @tempquery varchar(100), @tempquery2 varchar(100)
select @tempquery = "select tempkey = identity(6), empl_id into #temptable from empl"
exec (@tempquery)
select @tempquery2 = "select * from #temptable"
exec(@tempquery2)
end