Viewing 15 posts - 4,036 through 4,050 (of 4,080 total)
It ain't pretty, but it's a start. This will run faster than doing it with a cursor or a while loop.
You'll probably need to create another cte...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 10, 2008 at 5:34 pm
Maynor, looks like you need to PIVOT. There is another recent thread on that subject. Check it out.
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 9, 2008 at 4:15 pm
Left Joins or WHERE NOT EXISTS are the ways to go. Here's why.
I ran a little experiment using the LEFT JOIN technique versus EXCEPT. The...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 8, 2008 at 5:22 pm
CREATE TABLE #Conditional
(
StartDate datetime,
value float,
x int
)
INSERT INTO #Conditional
VALUES ('08/10/2008 01:48', 3, 0) -- starting out with a zero value in the new "x" column
etc
--------------------------------
declare @b-2 int
set @b-2...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 8, 2008 at 11:11 am
Jack's right. Good eye!
For what it's worth, I always use the left join format too. It's simple to remember, fast to execute, and easy...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 8, 2008 at 10:21 am
Well, to start with the outputs are different. Exists returns a true/false value, whereas except returns a set of 0-n rows. Why would you...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 8, 2008 at 9:38 am
This is not an optimal table design for doing what you want in SQL. It would be easier if your table was like this:
userName ...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 8, 2008 at 9:17 am
From the looks of things, all but two of the subqueries in your WHERE clause are used only to determine if a column has a match in another table. ...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 7, 2008 at 4:38 pm
Shame on you.
You are taking what should be three different columns and making one column out of them. Keeping date and sequence separate in your db...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 7, 2008 at 1:43 pm
If you simply truncate a table, indexes still exist but are empty. They are reloaded when you reload the underlying table.
Yes, building or loading indexes takes work, which...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 7, 2008 at 12:04 pm
Okay... so much for theory. I ran the code at the bottom (without DBCC FREEPROCCACHE or DBCC DROPCLEANBUFFERS) and saw no significant IO differences against the base...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 7, 2008 at 11:50 am
My bad. I didn't catch that the middle post was also from you. I see how using "AA" without a term qualification got you where...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 3, 2008 at 4:47 pm
Hey Craig:
By definition, in your joins, "A" only produces a set of rows for Fall 2008, just as "A2" can only return Summer 2008. As...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 3, 2008 at 4:33 pm
I've seen it done both ways. No best answer, it really depends on whether or not there is a hard and fast rule that says if-exists-then-update/if-not-exists-then-insert. ...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 3, 2008 at 4:10 pm
Nobody has unlimited budgets, so price is always a limiting factor. Therefore I cast my vote on the price/performance side of the house. Not that he needs...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 3, 2008 at 3:15 pm
Viewing 15 posts - 4,036 through 4,050 (of 4,080 total)