Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

How to create a temp table in a procedure rather than usinh INTO #temptable

$
0
0

Hello Please.,

I am having a quick question to automate something,


we have 10 procedures in Sql server 2008 R, each procedure having between 2000 lines to 3000 lines

in all procedures the temp tables used,

for example,

Select a.*, b.col1, c.col1, Case when d.col=1 then 'Match' else 'No Match' end as NewColumn
INTO #myTemp1
from
Table1 a join Table2 B on a.col1=b.col1 join Table3 C on a.col1 = c.col2 join Table4 D on b.col1=d.col3


So now the question is we have to change all procedures to create a temp table first then do insert into

So with above example

create table #Mytemp1
(Col1 Varchar(20) NULL,
 Col2 Varchar(2) NULL,
Co3 Date
)


Insert into #Mytemp1
Select a.*, b.col1, c.col1, Case when d.col=1 then 'Match' else 'No Match' end as NewColumn
------INTO #myTemp1  Done want to be happen this
from
Table1 a join Table2 B on a.col1=b.col1 join Table3 C on a.col1 = c.col2 join Table4 D on b.col1=d.col3

to do this it is taking big amount of time. also column lengths etc making some issues

so my request to you is.
is there anyway can i do this automatically creation of procedures etc.,

could somebody please help me with this

Thanks a lot in advance
Asiti

 


Viewing all articles
Browse latest Browse all 23857

Trending Articles