Viewing 15 posts - 76 through 90 (of 236 total)
Commonly, "SELECT *" is read as "SELECT ALL". Perhaps you've confused that?
August 2, 2010 at 12:06 pm
Ricardumus (8/2/2010)
SQL newb here. Can someone please step me through exactly what this variable assignment is
doing? Specifically "ELSE DATEADD(DD,-DATEPART(DW,@STARTDATE)+1"
SELECT @SUNDAY = CONVERT(VARCHAR(10)
,(SELECT CASE WHEN DATENAME(DW,@STARTDATE)
=...
August 2, 2010 at 11:13 am
I looked a little deeper, and a look-up table wouldn't be as elegant as I thought. It could still be done, and it would be fast, but it might...
August 2, 2010 at 10:12 am
My guess is that the code posted above with be several degrees slower than the original code. CASE statements, while they can be a mess to read, are quite...
August 2, 2010 at 8:46 am
I'm interested in this too. I would love to use this for log files.
August 2, 2010 at 8:19 am
dateadd(wk, datediff(wk, 0, @ThisDate), 0)
This will convert a date into the first Monday of the week that contains it. Group on this date.
Check out Lynn Pettis' wonderful one-stop-shop for...
August 2, 2010 at 8:15 am
I think your best bet is VARBINARY. You'll need something like a user-defined function to convert to and from the datatype, but there really isn't a better datatype for...
August 2, 2010 at 6:39 am
This definitely looks like you could join it against a Tally table or Date table.
August 2, 2010 at 6:24 am
That is a really creative way of avoiding using a cursor, but is it really getting around any of the problems with cursors? The primary problems with cursors are...
July 28, 2010 at 9:54 am
Ducati: You can use the parameters in the queries themselves. The query should already be a SELECT statement of some kind. You'd want to add something like this:
WHERE...
July 28, 2010 at 7:57 am
ISNULL() does exactly that:
ISNULL([Field],0)
This returns 0 if [Field] is NULL, otherwise it will return [Field].
But I prefer COALESCE() because it is a little more flexible:
COALESCE([Field],0)
The above code does exactly the...
July 28, 2010 at 7:19 am
Henry's code is better. I didn't even think to use a join for some reason. Use his second query.
--J
July 27, 2010 at 2:20 pm
bandgeek5454 (7/27/2010)
SELECT...
July 27, 2010 at 2:16 pm
No problem. I did the same thing, and thought the BOL was crazy. I wanted to know what was up too, so I did a little digging and...
July 27, 2010 at 2:08 pm
No worries. It may help you to look at the two tables. The one created from the Excel file should show dates, all of which have midnight as...
July 27, 2010 at 12:44 pm
Viewing 15 posts - 76 through 90 (of 236 total)