Forum Replies Created

Viewing 15 posts - 2,941 through 2,955 (of 4,085 total)

  • RE: CTE within a stored proc

    Lynn Pettis (8/28/2015)


    Lowell (8/28/2015)


    the command prior to WITH MyCTE AS(...

    must be terminated with a semicolon. that's probably where the issue likes.

    that issue makes a lot of people precede their...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: CTE within a stored proc

    mar.ko (8/28/2015)


    Ed Wagner (8/28/2015)


    The statement that contains the CTE needs to end with a query that uses the CTE. Like Luis said, please post the code; that should clear...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Cursor function and drop user/logon

    alemmon2 (8/28/2015)


    I figured since all versions are actually xx.xx.xxxx they would be greater or less than 10. In this case the GOTO is not an else as it is just...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Cursor function and drop user/logon

    The first thing I notice is that you are excluding SQL 2008. You have tests for > 10, and < 10, but not = 10.

    On a separate note, replace...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Varchar parameter Tinyint search criteria

    Jo6205 (8/27/2015)


    Hi All,

    I'm working in a stored procedure (not mine) and need to update a parameter. When a user runs the report, there is an option to pull jobs based...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Another SQL question, hopefull simple one

    For completeness, ordering by one of the partition expressions is pointless. The ORDER BY clause orders the records within the partition. Since all rows within a partition have...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Replace and Substring

    Also note that

    SUBSTRING(DOB,1,2)+SUBSTRING(DOB,3,2)

    is the same as

    SUBSTRING(DOB,1,4)

    I don't know if it will make a noticeable difference in performance, and I don't have the time to test it right now.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Designing Query

    This will generally perform much better than a UNION. I also replaced your TotalPrice * -1 using the unary operator.

    SELECT t.*

    FROM Accounts

    CROSS APPLY (

    VALUES('Asset', 'House', -TotalPrice)

    ,('Balance', 'Cover', TotalPrice)

    ) AS...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Can this be done without temp tables

    Lowell (8/19/2015)


    --first critieria

    SELECT OT.Week_id,OT.Jobnbr,OT.tasknbr FROM @data OT WHERE item_type = 'TASK' GROUP BY OT.Week_id,OT.Jobnbr,OT.tasknbr

    EXCEPT

    SELECT Week_id,Jobnbr,tasknbr FROM @data OH WHERE item_type = 'HOLD' AND item_id <> 'MATL' GROUP...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Can this be done without temp tables

    I think this is more efficient since it only requires reading the table once instead of three times.

    SELECT d.week_id, d.jobnbr, d.tasknbr

    FROM @data d

    GROUP BY d.week_id, d.jobnbr, d.tasknbr

    HAVING MIN(

    CASE

    WHEN d.item_type =...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: return the code that sp_MSforeachtable would produce

    ScottPletcher (8/19/2015)

    Be careful. The ? is replaced with a fully delimited schema and table, such as:

    [dbo].[table1]

    I didn't realize that was the case. In that case my query above...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: return the code that sp_MSforeachtable would produce

    You can use the following:

    SELECT t.TABLE_NAME, REPLACE(@cmd, '?', t.TABLE_NAME)

    FROM INFORMATION_SCHEMA.TABLES t

    The table name doesn't (typically) end with a ']', so it won't delete any records.

    Also '_' is a wildcard, so...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Help Needed in Relational Logic

    Eirikur Eiriksson (8/18/2015)


    Quick suggestion

    😎

    USE tempdb;

    GO

    SET NOCOUNT ON;

    declare @Process table(ProcessId int identity(1,1) primary key,ProcessName varchar(100),ParentStep int, ChildStep int);

    Insert into @Process(ProcessName,ParentStep,ChildStep)

    select 'Process1',1,2 union all

    select 'Process2',1,3 union all

    select 'Process3',1,6 union all

    select 'Process4',4,2 union...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Unable to link data from data pulled from XML

    Eirikur Eiriksson (8/14/2015)


    drew.allen (8/14/2015)


    Eirikur Eiriksson (8/14/2015)


    Further, I was only stating that with a properly written XQuery, using the text() function is much quicker, I was not commenting or comparing to...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Unable to link data from data pulled from XML

    Eirikur Eiriksson (8/14/2015)


    Further, I was only stating that with a properly written XQuery, using the text() function is much quicker, I was not commenting or comparing to yours or anyone...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

Viewing 15 posts - 2,941 through 2,955 (of 4,085 total)