Forum Replies Created

Viewing 15 posts - 586 through 600 (of 626 total)

  • RE: Using Case Within PIVOT portion of Crosstab query

    Try using the CASE statements in the top level SELECT.


    SELECT quote FROM brain WHERE original = 1
    0 rows returned

  • RE: Transaction Log grows extremely during online index rebuild

    Start here:

    http://www.sqlservercentral.com/stairway/72399/

    The stairway articles here are a great resource...but essentially a Clustered Index IS your table.


    SELECT quote FROM brain WHERE original = 1
    0 rows returned

  • RE: SQL Server 2012 MS Case Sentive?

    river1 (4/13/2015)


    Hi,

    I have a view named SGSCC

    If I call it as select * from SGSCC it works fine

    If I try to call it as select * from sgcc says that...


    SELECT quote FROM brain WHERE original = 1
    0 rows returned

  • RE: Help with a SQL Query

    Sean Lange (4/10/2015)


    Slightly off topic here but I have to ask. When you say In/Out what does True represent?

    This is wrong on a couple of levels. The first is...


    SELECT quote FROM brain WHERE original = 1
    0 rows returned

  • RE: Rolling 12month by item and market

    Sorry I used the wrong date in the APPLY. It should have been this:

    SELECT

    DATEPART(wk, t.date) AS [Week],

    t.*,

    x.Sales52

    FROM #Test t

    OUTER APPLY

    (

    SELECT SUM(sales) AS Sales52

    FROM #Test

    WHERE

    ([Date] BETWEEN DATEADD (wk, -52, t.date)AND...


    SELECT quote FROM brain WHERE original = 1
    0 rows returned

  • RE: Help with a SQL Query

    ...or you can cheese it a bit and do

    SELECT * FROM #TEST

    SELECT

    t.EmpCode,

    oa.TimeIn,

    t.Time AS [TimeOut]

    FROM

    #TEST t

    OUTER APPLY(

    SELECT MAX(Time) AS TimeIn FROM #TEST WHERE [TIME] < t.TIME AND [In/OUT] = 'TRUE'

    ) oa

    WHERE

    t.[In/Out]...


    SELECT quote FROM brain WHERE original = 1
    0 rows returned

  • RE: Help with a SQL Query

    This will get you most of the way.

    SELECT

    t.EmpCode,

    oa.TimeIn,

    t.Time AS [TimeOut]

    FROM

    #TEST t

    OUTER APPLY(

    SELECT MAX(Time) AS TimeIn FROM #TEST WHERE [TIME] < t.TIME AND [In/OUT] = 'TRUE'

    ) oa

    WHERE

    t.[In/Out] = 'FALSE'

    AND EmpCode =...


    SELECT quote FROM brain WHERE original = 1
    0 rows returned

  • RE: Rolling 12month by item and market

    Are you looking for something like this?

    WITH Last52 (Market, Item, Sales52)

    AS

    (

    SELECT

    Market,

    Item,

    SUM(sales) AS Sales52

    FROM

    #Test

    WHERE

    [Date] BETWEEN DATEADD (wk, -52, Date)AND GETDATE()

    GROUP BY

    Market,

    Item

    )

    SELECT

    DATEPART(wk, t.date) AS [Week],

    t.*,

    l.Sales52

    FROM #Test t

    JOIN Last52 l ON l.Market...


    SELECT quote FROM brain WHERE original = 1
    0 rows returned

  • RE: SQL Server Agent runs job successfully but reports failure

    Shouldn't have any reason to move the step. Just apply the logging to the one in question.

    Maybe try restarting the Agent and running again. I've seen my share...


    SELECT quote FROM brain WHERE original = 1
    0 rows returned

  • RE: Baffled by duplicates despite selecting distinct values

    Well the only thing left that I can think of is I sometimes forget to DROP or DELETE my temp tables when I testing some code. Maybe you ran...


    SELECT quote FROM brain WHERE original = 1
    0 rows returned

  • RE: Baffled by duplicates despite selecting distinct values

    Yes, that is correct...see easy to make a typo. 😉

    Hmmm...if it didn't return anything that is strange.


    SELECT quote FROM brain WHERE original = 1
    0 rows returned

  • RE: SQL Server Agent runs job successfully but reports failure

    How many steps do you have in your job and which one is reporting an error? The logging is applied to each step individually, so you'll need to make...


    SELECT quote FROM brain WHERE original = 1
    0 rows returned

  • RE: Baffled by duplicates despite selecting distinct values

    Your select statement that you posted doesn't guarantee unique values for OrderID.

    Just for fun just try:

    SELECT

    tinclude.OrderId,

    COUNT(tinclude.OrderId)

    FROM

    ( SELECT v.OrderId FROM dbo.mdv_CustomerFilterCustomerTransDate v WITH (NOLOCK)

    WHERE v.TerritoryCode IN (3) AND v.CustomerId...


    SELECT quote FROM brain WHERE original = 1
    0 rows returned

  • RE: Baffled by duplicates despite selecting distinct values

    Is that a typo in your Insert statement or did you forget the DISTINCT keyword?

    INSERT INTO #Context( OrderId )

    SELECT DISTINCT tinclude.OrderId FROM ( SELECT v.OrderId FROM dbo.mdv_CustomerFilterCustomerTransDate v WITH...


    SELECT quote FROM brain WHERE original = 1
    0 rows returned

  • RE: SQL Server Agent runs job successfully but reports failure

    I've had similar issues in the past. The problem is often the errors are very vague. Try editing the advanced option on your job step to 'Include step...


    SELECT quote FROM brain WHERE original = 1
    0 rows returned

Viewing 15 posts - 586 through 600 (of 626 total)