Forum Replies Created

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

  • RE: Get list of all the tables used in multiple SQL scripts

    I actually prefer using sys.dm_sql_referencing_entities. I found that I was getting false positives using the LIKE operator, because people had commented out sections of code, so the table name...

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

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

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

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

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

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

  • 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

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

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

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

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

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

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

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

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