Forum Replies Created

Viewing 15 posts - 2,881 through 2,895 (of 4,087 total)

  • RE: Show First Order With All of User Orders

    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

  • RE: Get previous row's value - with a twist!

    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...

  • RE: SQL Server Cursor

    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...

  • RE: Cursors

    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...

  • RE: Cursors

    tt-615680 (11/11/2015)


    I have tried "foreachdb but I'm unable to get any results at all, all I get is "Command completed successfully"

    running the following script:

    EXECUTE master.sys.sp_MSforeachdb 'USE [?];

    'DECLARE @sql VARCHAR(8000)...

  • RE: Issue with over partition looking for group by on a measure

    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...

  • RE: DY

    Luis Cazares (11/9/2015)


    How can a question and an affirmation be self-contradictory? I'm making the question because those are self explanatory for me, but if someone asks me what they mean,...

  • RE: UPDATE with OUTPUT CLAUSE

    j-1064772 (11/6/2015)


    -> J. Drew Allen

    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...

  • RE: DateAdd overflow using Numbers Table

    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...

  • RE: INT or BIGINT with leading Zeros

    No! Leading zeros are a display property and display properties are handled by the client application.

    Drew

  • RE: xml path approach for appending rows horizontally...

    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...

  • RE: UPDATE with OUTPUT CLAUSE

    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. ...

  • RE: Retail Week udf in TSQL

    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,...

  • RE: Create Function (I'm pulling my hair out)

    trevor.feller (11/3/2015)


    Hmmmm. Since I don't fully know what you've done, I'm having a hard time plugging this into the situation I need it to work within. I am...

  • RE: NULL and empty string question...

    Matt Miller (#4) (10/30/2015)


    Fair enough - I can see your point about simple expressions. That said - where is it notated that you could use a single expression in a...

Viewing 15 posts - 2,881 through 2,895 (of 4,087 total)