Viewing 15 posts - 286 through 300 (of 427 total)
ColdCoffee (9/4/2011)
And coming to my code, a 0-based will throw the CASE statement out of sync. That's why i din't use it 🙂
You're right, I had thought of that...
September 4, 2011 at 10:54 pm
Sean Lange (9/2/2011)
... but I still suggest you look into why you are using the nolock hint. It is ok and useful in some places but not always.
I would have...
September 4, 2011 at 8:04 am
For even cleaner code, your method needs a 0-based tally table. This is easily accomplished by adding -1 to row_number(). Your code then looks like this:
DECLARE @StartDATE DATETIME;
SET @StartDATE =...
September 4, 2011 at 7:50 am
Instead of doing a where count(*) > 1 it is often faster to check for duplicates by looking for any rows for which you can find at least one other...
September 2, 2011 at 11:56 am
Like Dave suggested, use row_number(), then add a little math, a crosstab and some string manipulation...
declare @tbl table (
EmpCode int not null,
ShiftDateTime datetime not...
September 2, 2011 at 11:18 am
Let's throw in some "modern" commands (not that they do anything good to the performance).
SELECT *
FROM @form
except
SELECT *
FROM @form
WHERE FromID = 3 OR FromID...
September 2, 2011 at 10:33 am
Neither pivot nor cross-tab. Just a simple trick using for xml path(). Does any length of texts (up to varchar(max) - 1), and any number of rows.
declare @tbl table (
...
September 2, 2011 at 10:08 am
Isn't the essence of your problem that you are trying to calculate off of percentages of a volume per shipment? In other words, shouldn't you store absolute quantities of the...
September 2, 2011 at 3:13 am
In this posting I presented an example on how to use a cte as the target for merge. The cte can be used to filter the rows to act upon...
September 2, 2011 at 2:36 am
No, that is not the merge command OP is describing. OP describes some sort of 2-way merge, updating the first table when there is a match, inserting missing records from...
August 31, 2011 at 2:00 pm
Without the internals of those views, their underlying tables and some test data we can not do much for you. Please provide some more details and people here will be...
August 31, 2011 at 1:02 am
And if you must do the formatting in T-SQL, you could replace the pivot by a crosstab. Then you can use max(), which allows for character strings to be handled,...
August 30, 2011 at 10:21 pm
I, for one, would be very interested to see a nested set implementation explained. I've read a lot about it and think it looks very promising, but I so far...
August 30, 2011 at 10:11 pm
Have a read at: http://msdn.microsoft.com/en-us/library/ms176057.aspx
An excerpt of this page:
"DBCC CHECKIDENT ( table_name, RESEED, new_reseed_value )
Current identity value is set to the new_reseed_value.
If no rows have been inserted into the...
August 30, 2011 at 2:51 pm
Sean Lange (8/30/2011)
August 30, 2011 at 2:28 pm
Viewing 15 posts - 286 through 300 (of 427 total)