Forum Replies Created

Viewing 15 posts - 2,551 through 2,565 (of 10,144 total)

  • RE: Correct index strategy for BETWEEN

    Jakub.Janda (3/24/2015)


    Statistics updated with fullscan, no change - still estimated 1 rows, actual 87k. I don't know why sql server chooses this plan, really, But, since the intervals do not...

  • RE: Correct index strategy for BETWEEN

    Hey Grant, in the Plan1 execution plan there's a NLIJ with "Expr1004" in the Outer References list. Any idea what the "Expr1004" is for and where it was constructed?

  • RE: Correct index strategy for BETWEEN

    Phil Parkin (3/24/2015)


    Actual rows and Est rows are very different. Are your statistics up to date?

    Agreed. We don't have index definitions yet either:

    SELECT TOP 1

    l.fkTblCountry,

    l.sCity

    FROM tblGeoIPLocation l

    INNER JOIN tblGeoIPBlock b...

  • RE: Replace string after a specific index

    sarath.tata (3/23/2015)


    I think I may better use Left in stead of Replace

    SELECT

    CASE WHEN CHARINDEX(' ', Supervisor, CHARINDEX(' ', Supervisor, 0) + 1) > 0 THEN

    LEFT(Supervisor, CHARINDEX(' ', Supervisor, CHARINDEX('...

  • RE: Replace string after a specific index

    CREATE TABLE #Names (Fullname VARCHAR(50))

    INSERT INTO #Names (Fullname)

    SELECT 'Potter, James J' UNION ALL

    SELECT 'Williams, Ted R' UNION ALL

    SELECT 'Allen, Gary G' UNION ALL

    SELECT 'Allen, Gary Graham' UNION ALL

    SELECT 'Allen, Gary...

  • RE: Data arrangement - columns to rows in a specific way

    Anju Renjith (3/23/2015)


    CodeIDTypeIDNameOrderGroupId

    9776210000061111DTaP/IPV/Hib11

    9776310000061141DTaP/IPV/Hib21

    9776410000061161DTaP/IPV/Hib31

    1540611000006110 6DTaP/IPV pre-school booster41

    9776610000061178dTaP/IPV 51

    4052810000001182PCV 12

    4053010000001172PCV ...

  • RE: Windows function version of the query if possible

    aslamnepanagar (3/23/2015)


    Hi Chris,

    Though the results are not matching . I like the logic.

    I keep it open for a day for any other approach else I will mark as solution.

    Aslam

    Can...

  • RE: Create View to allocate amount per month - financial year

    jaggy99 (3/22/2015)


    The amount 300,000 is a budget figure which I'm given. I'm just trying to use sql to blend data so thinking if I can create a view to spread...

  • RE: Windows function version of the query if possible

    aslamnepanagar (3/23/2015)


    Hi All,

    Need one help in the following query using adventureworks database.

    Select s.businessentityid,

    sum(s2008.salesquota) Total2008

    ,sum(s2007.salesquota) Total2007

    from sales.salesperson s

    left outer join sales.salespersonquotahistory s2008

    on s.businessentityid=s2008.businessentityid

    and year(s2008.quotadate)= 2008

    left outer join sales.salespersonquotahistory s2007

    on s.businessentityid=s2007.businessentityid

    and...

  • RE: DISTINCT use on views problem

    mattech06 (3/20/2015)


    Hi twin.devil,

    they sound like good suggestions but..

    check the execution plan - how?

    recompile option with timeout query - how?

    statistics properly updated - how?

    check if index is fragmented - how? -...

  • RE: set variable from openquery

    -- Tested and working

    DECLARE @Statement VARCHAR(1000), @Year SMALLINT, @AgencyCode VARCHAR(5)

    SELECT @Year = 2014, @AgencyCode = '57LHS'

    SET @Statement = '

    SELECT

    [Complaint Number] = QNUMBM,

    [Complaint Date] = QCMPDM,

    [Complaint Reason] =...

  • RE: Help with tsql querry

    raza.qadri (3/19/2015)


    job_order is primary key so always single value:

    ...

    Yes that's correct, however if more than one row are affected by an insert/update/delete, then the trigger tables will contain more than...

  • RE: Help with tsql querry

    Further to Gail's comments, Dwain Camps wrote this article [/url]just for you. Enjoy.

  • RE: Stairway to Advanced T-SQL Level 3: Understanding Common Table Expressions (CTEs)

    chris.puncher (3/19/2015)


    Alan B. - Welcome to the discussion. Things have moved on while I've been sleeping in the UK 🙂 Just to point out that in my case the CTEs...

  • RE: Assign Consecutive Numbers to a block of data

    DaPainKiller (3/18/2015)


    superb!!!Thanks a lot sir 🙂 🙂 🙂

    Final code:

    WITH cte AS

    (

    SELECTTestId,

    TestDate,

    --[GroupBy] = TestDate - rn,

    RANK() OVER (

    PARTITION BYTestId

    ORDER BYTestDate - rn

    )AS OrderId

    FROM(

    SELECTTestId,

    TestDate,

    ROW_NUMBER() OVER

    (

    PARTITION BY TestId

    ORDER BY...

Viewing 15 posts - 2,551 through 2,565 (of 10,144 total)