Viewing 15 posts - 226 through 240 (of 2,171 total)
Keep it simple and avoid any reference to SET DATEFIRST!
DECLARE@Year SMALLINT = 2011
;WITH cteCalendar(FirstOfMonth, LastOfMonth)
AS (
SELECTDATEADD(MONTH, 12 * @Year + number - 22801, 6) AS FirstOfMonth,
DATEADD(MONTH, 12 * @Year +...
N 56°04'39.16"
E 12°55'05.25"
October 27, 2010 at 1:23 pm
DECLARE@Sample TABLE
(
RowID INT IDENTITY(1, 1) PRIMARY KEY CLUSTERED,
Data VARCHAR(5) NOT NULL
)
INSERT@Sample
(
Data
)
SELECT'' UNION ALL
SELECT'1' UNION ALL
SELECT'11'
;WITH cte(Digit)
AS (
SELECT ' ' UNION ALL
SELECT '1'
)
INSERT@Sample
(
Data
)
SELECTp1.Digit + p2.Digit + '.' + p4.Digit + p5.Digit
FROMcte...
N 56°04'39.16"
E 12°55'05.25"
September 7, 2010 at 1:27 pm
Also asked and answered here multiple times.
SELECTBranchName,
SUM(CASE WHEN [Status] = 'A' THEN Amount ELSE 0 END) AS Active,
SUM(CASE WHEN [Status] = 'D' THEN Amount ELSE 0 END) AS Cancel
FROMdbo.Rose
GROUP BYBranchName
N 56°04'39.16"
E 12°55'05.25"
September 6, 2010 at 1:55 am
What does this query return?
SELECT MAX(LEN(PARSENAME('0.' + Col1, 1))) AS Part1,
MAX(LEN(PARSENAME('0.' + Col1, 2))) AS Part2
FROM Table1
WHERE Type = 'ABC'
N 56°04'39.16"
E 12°55'05.25"
September 4, 2010 at 10:10 am
Paul White NZ (9/3/2010)
N 56°04'39.16"
E 12°55'05.25"
September 3, 2010 at 1:18 pm
Paul... If you change index IXC_Transaction_AccountID_Date_TransactionDetailID for DATE column to be descending, your CTE update fails.
This behaviour is covered both here (and a correct implementation of "Ordered CTE Update") http://www.simple-talk.com/sql/performance/writing-efficient-sql-set-based-speed-phreakery/%5B/url%5D
and...
N 56°04'39.16"
E 12°55'05.25"
September 3, 2010 at 8:15 am
Can you wait a few minutes? I just ran out of popcorn and soda...
N 56°04'39.16"
E 12°55'05.25"
September 3, 2010 at 4:35 am
Also asked and answered her http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=149677
N 56°04'39.16"
E 12°55'05.25"
September 3, 2010 at 1:31 am
This line seems to be obselete, unless it's used for filtering? It is not used in the resultset.
INNER JOIN ltf.sforce.Contact AS ReferrerContact ON ReferrerContact.Id = Prospect__c.Referring_Member__c
In...
N 56°04'39.16"
E 12°55'05.25"
September 2, 2010 at 7:50 am
dingels35 (9/2/2010)
I am under the assumption that a clustered index should always be better than a non-clustered index, even if the non-clustered index covers all columns in the query.
It depends...
N 56°04'39.16"
E 12°55'05.25"
September 2, 2010 at 7:10 am
Three suggestions.
1) Alter existing index
CREATE NONCLUSTERED INDEX [IX_Contact_1] ON [sforce].[Contact]
(
[Join_Date__c] ASC,
[Member_Type__c] ASC,
[Member_Status__c] ASC,
[AccountId] ASC
) INCLUDE ( [LastName], [FirstName], [Email], [MMS_Member_ID__c] )
2) Create new index
CREATE NONCLUSTERED INDEX [IX_Account_2] ON [sforce].[Account]...
N 56°04'39.16"
E 12°55'05.25"
September 2, 2010 at 6:26 am
Also, don't use functions in WHERE clauses. The function is evaluated for every row!
Replace "dbo.floorDate(DATEADD(d,-30,GETDATE()))"
with
DATEADD(DAY, DATEDIFF(DAY, 30, GETDATE()), 0)
This expression is only evaluated once in the query.
N 56°04'39.16"
E 12°55'05.25"
September 2, 2010 at 1:31 am
dingels35 (9/1/2010)
Looking at the statistics profile, it's obvious that the 160k executes against Account is bad. I am unsure of why this is happening. Any ideas?
I am much...
N 56°04'39.16"
E 12°55'05.25"
September 2, 2010 at 1:28 am
It is a set-operation and it looks like MERGE internally divides the records into three streams based on current data.
One stream for DELETE, one stream for UPDATE and one stream...
N 56°04'39.16"
E 12°55'05.25"
September 1, 2010 at 3:38 pm
urmarke (9/1/2010)
N 56°04'39.16"
E 12°55'05.25"
September 1, 2010 at 3:14 am
Viewing 15 posts - 226 through 240 (of 2,171 total)