Viewing 15 posts - 2,176 through 2,190 (of 4,087 total)
TheSQLGuru (11/4/2016)
Well done Drew. Especially nice given the added flexibility. 2 very minor improvements:
Thanks. I did consider including the first improvement, but decided to go with the less efficient...
November 4, 2016 at 9:55 am
I don't see a question here. If you're asking what the best approach to use is, it really depends a lot on what skills you have.
Personally, I like SSIS,...
November 4, 2016 at 9:40 am
Both Mark's and Kevin's solutions use a non-SARGable join. Here is a version where the join is SARGable. It also allows for variable length ranges. If you...
November 4, 2016 at 9:12 am
ScottPletcher (11/3/2016)
drew.allen (11/3/2016)
ScottPletcher (11/3/2016)
November 3, 2016 at 4:35 pm
You should NOT be using SQL Profiler, which has been deprecated. You should be using extended events.
Drew
November 3, 2016 at 4:16 pm
Assuming that the obvious solution isn't what you were looking for, try the following.
SELECT
CID,
MyCodes,
SUM(CASE WHEN MyCodes IN ('Full', 'part', 'Contract') THEN Hours END),
FROM MyClrTbl
GROUP BY ID, MyCodes
Although, it looks like...
November 3, 2016 at 4:13 pm
ScottPletcher (11/3/2016)
I avoid the ISNULL "tricks" when I can in favor of straightforward code:UPDATE table_name
SET Foo = CASE WHEN Foo > '' THEN ', ' ELSE '' END + 'newvalue'
I...
November 3, 2016 at 2:39 pm
hegdesuchi (11/3/2016)
Thank you!
I used distinct and got the answer.
I have to stage the data from XML file into different tables and then use joins to put them...
November 3, 2016 at 2:25 pm
ScottPletcher (11/3/2016)
November 3, 2016 at 2:14 pm
Yes, I forgot to move the ORDER BY clause to the main query when I copied the first query to create the second query.
There is an extra END in the...
November 3, 2016 at 2:00 pm
I think that UNPIVOT/PIVOT is overkill for this particular situation. I was able to get very close to your results using four simple CASE expressions.
SELECT *
,CASE WHEN wtt.Status =...
November 3, 2016 at 10:20 am
This looks like actual patient data. If so, it is a serious HIPAA violation. We don't need the name and phone number to solve your issue and it...
November 3, 2016 at 9:43 am
I stated on another thread that the number of different posts for this same query indicate that the OP is purposely fragmenting the discussion to hide the complexity of the...
November 3, 2016 at 8:56 am
The problem is here:
Insert Into Product (CustomerID, ProductId, OrderID, Quantity, Date1)
SELECT @CustomerID, @ProductId, @OrderID, 1, GETDATE()
From Product Where ProductId = @ProductId And CustomerID = @CustomerID AND OrderID <> @OrderID
UNION
SELECT...
November 3, 2016 at 8:40 am
Given the numerous threads the OP has started on what appears to be the same exact query, I think that this task is simply too complex to be handled in...
November 2, 2016 at 3:20 pm
Viewing 15 posts - 2,176 through 2,190 (of 4,087 total)