I want to insert dynamic record in temporary table. I don't want to declare this table. I want its columns to be defined at run time. I am doing this because definition of table "Contract" may change in future. So temporary table(#x) should be changed accordingly. And this will be in a Stored Procedure.
I have tried following ways(which were marked as answers, none works though)
EXECUTE IMMEDIATE
'SELECT top 1 * FROM Contract'
INTO #x
select * from #x
declare @arj varchar(100)
set @arj= 'SELECT top 1 * FROM Contract'
select * into #x from
(SELECT top 1 * FROM Contract)
declare @arj varchar(100)
set @arj= 'SELECT top 1 * FROM Contract'
SELECT * into #x execute ('execute' +
--and this-- SELECT into #T1 execute ('execute ' + @SQLString ) @arj )
SELECT *from #x