Viewing 15 posts - 2,881 through 2,895 (of 4,087 total)
MIN won't always give the correct answer, because the first order may not be the smallest order. You want to use FIRST_VALUE instead of MIN.
Drew
November 16, 2015 at 8:07 am
Just because LAG/LEAD is shiny and new, doesn't mean that it's the best approach for the job. If you were trying to do this on SQL 2008, you would...
November 16, 2015 at 8:03 am
You're executing your sql command in a TRY/CATCH block, but you're discarding any errors that you receive. How do you expect to troubleshoot your code if you're discarding all of...
November 13, 2015 at 12:32 pm
I just realized that you're only running the query if a table with an empty name exists. You CANNOT create a table with an empty name, so your query...
November 11, 2015 at 11:49 am
tt-615680 (11/11/2015)
running the following script:
EXECUTE master.sys.sp_MSforeachdb 'USE [?];
'DECLARE @sql VARCHAR(8000)...
November 11, 2015 at 11:45 am
DamianC (11/11/2015)
Can anybody see where I am going wrong?
Yes, you can't mixed windowed and windowless aggregates in the same SELECT clause. If I understand what you want, you'll want to...
November 11, 2015 at 8:44 am
j-1064772 (11/6/2015)
Composable DML [/url]lifts some of those restrictions. For our team, being able to augment the OUTPUT columns with other data and then filter before inserting into...
November 6, 2015 at 2:35 pm
In your first query, the engine first has to evaluate the DATEADD before it can evaluate the condition. Since you have numbers that cause an overflow when evaluating the...
November 5, 2015 at 2:43 pm
No! Leading zeros are a display property and display properties are handled by the client application.
Drew
November 5, 2015 at 2:22 pm
Try the following:
SELECT
E.[USER_NAME] As 'User Name',
(
SELECT ',' + C.[PERMISSION_NAME]
FROM TABLEA As A
JOIN TABLEB AS B ON A.PK_OBJ_ID = B.FK_APP_OBJECT_REF
JOIN TABLEC AS C ON C.PK_PERMISSION_ID = B.FK_PERMISSION_REF
JOIN TABLED AS D ON...
November 4, 2015 at 8:20 am
The OUTPUT clause is very limited. You can either output the data directly to the client application or you can output your data to a table/table variable. Period. ...
November 4, 2015 at 8:15 am
Assuming that you have a calendar table, the following variation on a gaps and islands solution will work:
WITH retail_weeks AS (
SELECT rdt.retail_year, rdt.retail_dt
, ROW_NUMBER() OVER(PARTITION BY rdt.retail_year ORDER BY cal.dt,...
November 3, 2015 at 11:02 am
trevor.feller (11/3/2015)
November 3, 2015 at 8:51 am
Matt Miller (#4) (10/30/2015)
November 2, 2015 at 7:17 am
Viewing 15 posts - 2,881 through 2,895 (of 4,087 total)