|
|
-
Dwain Camps Commented 4 Months ago through Blogs
SELECT DATEADD(month, 1, GETDATE()-DAY(GETDATE()))
Was just kind of a guess without a lot of testing. Fortunately I always use the one below which is faster than all but eomonth():
SELECT DATEADD(mm,DATEDIFF(mm,-1,GETDATE()),-1)...
|
-
Dwain Camps Commented 4 Months ago through Blogs
I think this way is faster than any of the non-SQL 2012 versions you propose:
SELECT DATEADD(mm,DATEDIFF(mm,-1,GETDATE()),-1)
Then of course there is this way that beats 2 of 4 of your non-SQL 2012 solutions and has the advantage of being pretty r...
|
-
Dwain Camps Commented 6 Months ago through Blogs
Try adding this to your test data:
UNION ALL SELECT '9999999999'
And watch this error emerge for the first case:
Msg 248, Level 16, State 1, Line 14
The conversion of the varchar value '9999999999' overflowed an int column.
Suggest you refe...
|
-
Dwain Camps Commented 6 Months ago through Blogs
If you ask me, you should use Paul White's super fast DISTINCT method.
http://www.sqlservercentral.com/Forums/Topic873124-338-5.aspx#bm1013407...
|
-
Dwain Camps Commented 9 Months ago through Blogs
One more link. This article was pending publication when I made my prior post.
http://www.sqlservercentral.com/articles/CROSS+APPLY+VALUES+UNPIVOT/91234/
There are some interesting performance characteristics of this method if you read the articl...
|
-
Dwain Camps Commented 10 Months ago through Blogs
This method of using CROSS APPLY VALUES for UNPIVOT is described in both of the following links:
[Spotlight on UNPIVOT by Brad Schulz][1]
[Unpivoting data by Itzik Ben-Gan][2]
In case anyone is interested in more information.
[1]: http://b...
|
-
Dwain Camps Liked 11 Months ago through Pages
We wish to use these pages for publishing various documents, announcements, FAQ etc related to beyondrelational.com...
|
-
Dwain Camps Commented 11 Months ago through Blogs
If I was the interviewee, I probably wouldn't accept a job at your company because this question has no analogy in the real world.
Adding two dates together is completely meaningless. Sure some people store a time duration in a DATETIME field and th...
|
-
Dwain Camps Commented 1 Years ago through Puzzles
No need to have SQL Server 2012 to use windowing functions although I do understand there are some new ones in 2012 that might make it easier. I did use PARTITION for my SQL Server 2005 solution.
|
-
Dwain Camps Solved 1 Years ago through Puzzles
Sorry but I just submitted this solution a few minutes ago without a login.
Explanation:
cte1 - Assigns the Episode ID to the records that have IntervalDate
cte2 - Selects the records that do not have an IntervalDate
cte3 - UNIONs cte1 with cte2 whil
|