Viewing 15 posts - 3,601 through 3,615 (of 4,085 total)
Here is a sample of the batch file. You have to specify the server and database separately, so the IF statement is setting up different environment variables for each.
if...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
September 26, 2011 at 1:08 pm
This will also give you the correct results. I suspect it might be more efficient than having the two separate subqueries, but haven't had a chance to test it.
SELECT...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
September 26, 2011 at 12:48 pm
mw112009 (9/26/2011)
We have 6 servers and I have to deploy many stored procs in each of these servers. Doing them manually is a pain. Besides I run into situations where...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
September 26, 2011 at 12:37 pm
Your English statement of the criteria does not match the expected results. Transaction_IDs 1-8 all have an instance of Type A, so they should all be included in your...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
September 26, 2011 at 11:56 am
As I suggested earlier, you probably want to use a CTE with Row_Number()
WITH POLineItems AS (
SELECT A.OrdN03
...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
September 23, 2011 at 9:43 am
You just need to use slightly different syntax.
SELECT p.escProduct AS ep, count(*) as totEsc,
CASE WHEN o.ocDateClosed IS NULL THEN
avg(DATEDIFF(DAY, o.ocDateOpened, GETDATE()))
ELSE avg(DATEDIFF(DAY, o.ocDateOpened, o.ocDateClosed))
End AS 'srAge'
FROM tblocMain o INNER JOIN...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
September 23, 2011 at 8:07 am
What you're asking to do violates basic principles of database design. Why do you need to do this?
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
September 23, 2011 at 7:59 am
HowardW (9/22/2011)I also fundamentally disagree that the purpose of documentation isn't to be accurate.
No one said that it wasn't the goal. What I was trying to say is that...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
September 22, 2011 at 2:34 pm
This should give you what you need. It's not tested.
SELECT OrgID, Count(IndID)
FROM Individuals AS i
CROSS APPLY(
SELECT TOP (1) OrgID
FROM Transactions AS t
WHERE t.IndID = i.IndID
ORDER BY TranID
) AS t
GROUP...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
September 22, 2011 at 2:02 pm
You don't need to supply a real datetime for the 99999999. Min() and Max() will only return NULL if all of the values are NULL, but that's what you...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
September 22, 2011 at 1:40 pm
With appropriate indices, a CROSS/OUTER APPLY should perform better, but you should test it with your actual data. An OUTER APPLY corresponds to the LEFT JOIN that you are...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
September 22, 2011 at 12:52 pm
HowardW (9/21/2011)
Maybe I'm misreading, or is this a mistake in BOL? (you'd think not for the amount this article is used)
Manuals are not technical specs nor are they gospel. ...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
September 22, 2011 at 10:46 am
duanecwilson (9/21/2011)
I had been working on a larger query that surrounded this one
In that case, you might consider using a CROSS APPLY instead of Max().
SELECT DayKey, Port_ID
FROM <<Main Query>>
CROSS APPLY...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
September 22, 2011 at 9:53 am
HowardW (9/21/2011)
The style parameter has nothing to do with converting a varchar/char to a datetime.
You might want to recheck your facts. BOL says differently:
http://msdn.microsoft.com/en-us/library/ms187928.aspx
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
September 21, 2011 at 2:07 pm
Pam Brisjar (9/21/2011)
Drew: Your solution, unfortunately, didn't work. Seems like a select statement in a CASE isn't allowed.
Actually a SELECT statement should be allowed as long as it only...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
September 21, 2011 at 9:11 am
Viewing 15 posts - 3,601 through 3,615 (of 4,085 total)