January 29, 2010 at 10:41 am
I am reviewing some stored procedures coded by the previous DBA.
I see the following construct repeated though out the code:
select * into pqchildren from #pqchildren
drop table pqchildren
Can someone explain to me why this coding pattern would useful?
January 29, 2010 at 12:01 pm
the only reason i can think he would have done that is because when he does the "into" statment he is actually creating a real table w/ that name and those records from the select. Normally you would do that if you have other stored procedures or processes that will reference this newly created table.
January 29, 2010 at 12:02 pm
so when he's running
select * into pqchildren from #pqchildren
then whatever db you are in you will see a new table called pqchildren
the below will obviously drop the newly created table
drop table pqchildren
January 29, 2010 at 12:28 pm
The funny part of the code is that the two statements always follow one another with no other code in between.
I was thinking that somehow the code was throwing data into memory, but that did not really make sense either.
January 29, 2010 at 12:57 pm
sounds like bad code to me.......i would hesitate changing it late friday unless ur glutton for punishment.
I grew up w/ a mike french. ur not from florida are u?
January 31, 2010 at 4:00 am
michael.french 172 (1/29/2010)
Can someone explain to me why this coding pattern would useful?
That looks like an ugly workaround for something the previous guy didn't know how to do properly.
Check for a database trigger fired on create table events - there might be some sort of dumb auditing scheme in place...?
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply