Forum Replies Created

Viewing 5 posts - 1 through 5 (of 5 total)

  • RE: CTE within a stored proc

    Sometime tells me Microsoft does not even want you creating temporary views.

    CREATE VIEW #TestView AS (

    SELECT 1 as a

    )

    Returns

    Msg 4103, Level 15, State 1, Line 1

    "#TestView": Temporary views are not...

  • RE: Obtaining earliest change for one colum?

    Forgot the entity chunk. Yes you will need a CTE and a Row_Number function.

    [Code]

    DECLARE @EntityID INT = 123;

    WITH cte

    AS (

    SELECT row_Number() OVER (ORDER BY Audit_ID) AS RN

    ...

  • RE: Obtaining earliest change for one colum?

    You were on the right track with the self join

    SELECT t1.ActionDate, t1.Field_B

    FROM #test t1

    LEFT JOIN #test t2 ON t1.Audit_ID = t2.Audit_ID-1

    WHERE t1.Field_B != t2.Field_B OR t2.Audit_ID IS NULL

  • RE: Begginer Sub Query problem

    Something like this should work for you

    SELECT c1.CompanyName

    ,c1.CompanyID

    ,c1.Heirarchy

    ,c2.CompanyName

    FROM Company c1

    LEFT JOIN Company c2 ON c1.parentCompanyID = c2.CompanyID

  • RE: t-sql trimming before and after stored proc name

    Is there a reason you cant do SELECT p.name FROM sys.procedures p ?

Viewing 5 posts - 1 through 5 (of 5 total)