Forum Replies Created

Viewing 15 posts - 6,136 through 6,150 (of 7,613 total)

  • RE: Using CAST or CONVERT to change data from string to datetime

    I suggest:

    1) be sure to pad the month and day values so that the final format is a full yyyymmdd.

    2) apply column names to make the code easier to understand...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Select Only Rows with Alphabetical Character in Column

    WHERE

    column_name LIKE '[a-z]%'

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Query optimization help

    Lynn Pettis (4/17/2014)


    ScottPletcher (4/17/2014)


    Lynn Pettis (4/17/2014)


    ScottPletcher (4/17/2014)


    You need to do further research before you change the existing index to a filtered index, because that index will no longer satisfy queries...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Metrics to determine switch to Enterprise

    SpeedySQL (4/17/2014)


    If you're considering upgrading to SQL 2012, be aware that the licensing model is changing to per core. Another factor you may want to look at apart from...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Query optimization help

    Lynn Pettis (4/17/2014)


    ScottPletcher (4/17/2014)


    You need to do further research before you change the existing index to a filtered index, because that index will no longer satisfy queries originally using it...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Query optimization help

    You need to do further research before you change the existing index to a filtered index, because that index will no longer satisfy queries originally using it if you filter...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Looking for elegant solution! Finding match over multiple rows

    gbritton1 (4/16/2014)


    Or, in that same snippet, take advantage of the fact that you initialize the variable @CompleteSetFound to 0 in the declaration. Then you can simplify to:

    IF EXISTS (

    ...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Looking for elegant solution! Finding match over multiple rows

    I think this coding could theoretically perform better:

    ...

    IF (@AnimalsFound = 1)

    BEGIN

    SET @CompleteSetFound =

    CASE WHEN EXISTS(SELECT

    1

    FROM @FarmMatches ri

    INNER JOIN [dbo].[Animal] ani ON ani.[FeatureID] = ri.[OverallID]

    GROUP BY

    FeatureID, Code

    HAVING

    MAX(CASE WHEN TypeName...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Query optimization help

    I suggest changing one of your existing indexes to also cover this query:

    CREATE NONCLUSTERED INDEX [AI_OperatorCBGEstimate_14947]

    ON OperatorCBGEstimate ( DateEndedStandard, UpdOperation )

    ...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Looking for elegant solution! Finding match over multiple rows

    I've coded checks for just Animal table groupings. Please check and see if it produces the results you want.

    Edit: This is doing only full matches but partial matches could...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: SQL script to LOOP in and find sequence gap on Unique column

    It's possible but it's huge overhead you should probably avoid.

    You can use ROW_NUMBER() to sequentially number the data when you read it rather than having to physically update the values...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Eliminating duplicates while insert

    You could try something like this and see if it helps:

    WITH cte_OrderProjectType AS

    (

    select A.Orderid, min(B.TypeID) , min(C.CTType) , MIN(D.Area)

    from tableA A inner join (

    select PID,...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Eliminating duplicates while insert

    Please add an alias to columns in the SELECT:

    select ?.Orderid, min(?.TypeID) , min(?.CTType) , MIN(?.Area)

    Otherwise we can't really rewrite any of the code.

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: help on datediff

    What specifically does the data in the "Verdate" look like?

    For example, is it 'yyyymmdd hh:mm'?

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Deadlock prediction

    First properly tune the indexes, in particular getting the correct clustering index (hint: very often this means not clustering on an identity column). That is usually the single biggest...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

Viewing 15 posts - 6,136 through 6,150 (of 7,613 total)