Forum Replies Created

Viewing 15 posts - 4,981 through 4,995 (of 10,144 total)

  • RE: calculating period of time

    astrid 69000 (3/26/2013)


    but if i create the date table dont i have to add the dates manually?

    to calculate the first period i go

    select sum(Count) from #table where recordday >= '2008-01-01'...

  • RE: Assistance with this query

    ;WITH Employees AS (

    SELECT TOP 1

    employeeid,

    FIRSTNAME,

    LASTNAME,

    EMAILADDRESS,

    STARTDATE

    FROM linkedServer.linkedDB.dbo.AUEMPLOYEE

    WHERE employee.ENDDATE IS NULL -- still active

    ORDER BY ACTIONDATE DESC -- most recent

    )

    SELECT

    e.*,

    org.ORGANIZATIONID,

    job.JOBTITLEID

    FROM Employees e

    LEFT...

  • RE: calculating period of time

    astrid 69000 (3/26/2013)


    Chris that but I need to add each row manually which I didn’t want to do (this is the one thing I know how to do lol.

    Jayanth, I...

  • RE: Reorder a custom order column

    matak (3/26/2013)


    Expected output where @startNum < @oldnum (startnum 2 oldnum 4)

    changedinitial

    11

    32

    43

    24

    55

    66

    77

    88

    3 rows affected

    Expected output where @startNum > @oldnum (startnum 4 oldnum 2)

    changedinitial

    11

    42

    33

    24

    55

    66

    77

    88

    Two rows affected

    Are these both correct? The second sample...

  • RE: calculating period of time

    Does this help?

    ;WITH MyData ([day], [Count]) AS (

    SELECT '2008-01-01 00:00:00.000', 3 UNION ALL

    SELECT '2008-01-01 11:00:00.000', 9 UNION ALL

    SELECT '2008-01-01 22:00:00.000', 3 UNION ALL

    SELECT '2008-01-02 09:00:00.000',...

  • RE: Performance Problem In a Procedure

    Chandan, you're very welcome, thank you for your generous feedback.

    This exercise, resolving a simple query from a more complex query referencing many more objects, often isn't successful because of cardinality...

  • RE: Deadlock on update command

    bugg (3/25/2013)


    ChrisM@Work (3/25/2013)


    This article linked in my sig explains in detail how to post execution plans. They're active - .png graphics are not.

    Right-click on the execution plan tab, select...

  • RE: Deadlock on update command

    OK got it. You need to change two indexes.

    1. Include orderhash and status in index IX_SessionID, like this:

    CREATE NONCLUSTERED INDEX [IX_sessionid] ON [dbo].[orderha]

    ([sessionid] ASC, OrderHash ASC) INCLUDE (Status)

    2....

  • RE: Deadlock on update command

    This article linked in my sig explains in detail how to post execution plans. They're active - .png graphics are not.

    Right-click on the execution plan tab, select "Save Execution...

  • RE: Deadlock on update command

    bugg (3/25/2013)


    ChrisM@Work (3/25/2013)


    bugg (3/25/2013)


    After applying that index update. I am now receiving another deadlock on that same table:

    Node:1

    KEY: 9:72057602492792832 (860067b2b9d1) CleanCnt:2 Mode:X Flags: 0x1

    Grant List 2:

    Owner:0x0000000198215A40 Mode: X Flg:0x40...

  • RE: Deadlock on update command

    bugg (3/25/2013)


    After applying that index update. I am now receiving another deadlock on that same table:

    Node:1

    KEY: 9:72057602492792832 (860067b2b9d1) CleanCnt:2 Mode:X Flags: 0x1

    Grant List 2:

    Owner:0x0000000198215A40 Mode: X Flg:0x40 Ref:1 Life:02000000...

  • RE: Problem in 1 Billion Records Table

    Si Thu (3/24/2013)


    Hi,

    I have one huge table which has 1Billion records. I tried to delete unnecessary records but it took a lot of time to delete and the delete was...

  • RE: Add variable number of rows into a table based on the values in another table (without cursors/while loops)

    Lynn Pettis (3/22/2013)


    Megha P (3/22/2013)


    Hello ,

    you can also try below

    ;WITH CTE AS

    (

    SELECT docid,pages FROM #x

    UNION ALL

    SELECT C.docid,C.pages-1

    FROM #x X INNER JOIN CTE C

    ON X.docid =...

  • RE: Performance Problem In a Procedure

    It's difficult to tell with all of those funky joins and no sample data, but you might get a win with this too;

    SELECT CAST(ID AS NUMERIC(9))

    INTO #Accounts

    FROM dbo.SplitIDs(@vcAccountId, ',')

    SELECT ...

  • RE: Performance Problem In a Procedure

    Most folks put in this situation will look for a quick win to buy the time necessary for the complete overhaul which Grant correctly recommends.

    I think you have some...

Viewing 15 posts - 4,981 through 4,995 (of 10,144 total)