|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Monday, July 04, 2011 4:13 AM
Points: 191,
Visits: 55
|
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Monday, July 04, 2011 6:16 AM
Points: 15,
Visits: 48
|
|
It's actually cool. Thanks a lot. Have you test it for large tables, with joins?
I have recently checked it uses to be faster sometimes to create the temporal table (t) instead of using that feature you have used, specially when further joins are going to be declared linking the "temporal" table created on the fly in this case inside parenthesis ()t.
Have a good day!
|
|
|
|
|
Right there with Babe
      
Group: General Forum Members
Last Login: Friday, May 10, 2013 11:54 AM
Points: 749,
Visits: 3,767
|
|
Very good! Thank you.
It surprises me that the DELETE statement works because I would have thought that the table would have to be explicitly named, but it works nevertheless.
______________________________________________________________________ The greatest enemy of knowledge is not ignorance, it is the illusion of knowledge. - Stephen Hawking
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Thursday, January 31, 2013 8:01 AM
Points: 1,232,
Visits: 1,046
|
|
This was done in a single script, but not a single query.
The insert into the #temp table is executed as a seperate query.
You would need to start with the use of a WITH table statement, or a derived table to get this done to a single query.
Interesting way to resolve a bad table design issue without correcting the bad table design.
|
|
|
|
|
Right there with Babe
      
Group: General Forum Members
Last Login: Friday, May 10, 2013 11:54 AM
Points: 749,
Visits: 3,767
|
|
SanDroid (7/5/2011) This was done in a single script, but not a single query.
The insert into the #temp table is executed as a sperate query.
You would need to start with the use of a WITH table statement, or a derived table to get this done to a single query.
Interesting way to resolve a bad table design issue without correcting the bad table design.
At times you have to work with less than perfect data even if it's no fault of your own.
Also, in my estimation, the "single query" push is a little overrated. What's the advantage of a single query? Performance can be enhanced in some cases with more than one query. So performance itself can't always be the answer.
______________________________________________________________________ The greatest enemy of knowledge is not ignorance, it is the illusion of knowledge. - Stephen Hawking
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Thursday, January 31, 2013 8:01 AM
Points: 1,232,
Visits: 1,046
|
|
mtillman-921105 (7/5/2011)
SanDroid (7/5/2011) This was done in a single script, but not a single query.
The insert into the #temp table is executed as a sperate query.
You would need to start with the use of a WITH table statement, or a derived table to get this done to a single query.
Interesting way to resolve a bad table design issue without correcting the bad table design.At times you have to work with less than perfect data even if it's no fault of your own. Also, in my estimation, the "single query" push is a little overrated. What's the advantage of a single query? Performance can be enhanced in some cases with more than one query. So performance itself can't always be the answer.
The name of the article compared to it's syntax and content inspired the entire post. Please do not confuse my comments on the authors odd word choice in this article as a personal opinion on some subject that was not mentioned.
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Thursday, September 27, 2012 12:07 PM
Points: 21,
Visits: 74
|
|
SanDroid (7/5/2011) This was done in a single script, but not a single query.
The insert into the #temp table is executed as a seperate query.
You would need to start with the use of a WITH table statement, or a derived table to get this done to a single query.
Interesting way to resolve a bad table design issue without correcting the bad table design. Maybe I'm wrong, but I think all of the #temp table stuff was just to have sample data to show how the technique works. He could have just written something like:
Delete T From (Select Row_Number() Over(Partition By [fld1],[fld2],[fld3],[fld4] order By [fld1]) As RowNumber,* From [tablename])T Where T.RowNumber > 1
and then explained that the partition clause needs to include all of the fields. Instead, he included a concrete example.
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Thursday, May 16, 2013 7:39 AM
Points: 315,
Visits: 1,352
|
|
Yeah, it's cool; I didn't know you could do this. I was getting this type of thing done by, and I'll use the C word, a cursor. 
Ken
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Thursday, January 17, 2013 5:49 AM
Points: 2,
Visits: 36
|
|
Thanks a lot for the script a rather easy and better way to do the job.
|
|
|
|