Forum Replies Created

Viewing 15 posts - 6,661 through 6,675 (of 7,613 total)

  • RE: Query to find cheapest supplier when multiple suppliers?

    I thought my query might meet the stated requirement while knocking out the second table scan :-).

    If OP does need to list the alternate supplier(s), then yes, I think some...

    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 to find cheapest supplier when multiple suppliers?

    Poor HAVING, nobody likes him 🙂

    SELECT

    ProductID, BaseSupplierID,

    MIN(CASE WHEN SupplierID <> BaseSupplierID THEN Price END) AS LowestPrice,

    MIN(CASE WHEN SupplierID...

    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: adding a new not null bit column with default 0

    You could also make the "real" column name a computed column that the developers use, and based off a "dummy name" column so they don't have to deal with NULLs....

    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: adding a new not null bit column with default 0

    Can you just add the column with no default value, for now, and handle the NULLs in the code temporarily?

    It's almost certainly applying the default value that is taking the...

    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: maximum rows without duplication

    select

    a.a, a.b, a.c

    from @a a

    left outer join (

    select b

    from @a a2

    group by b

    ...

    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 query 4 weeks 3 business days

    David Mando (3/11/2013)


    Thanks so much for your quick response.

    How would I write this query if it is just (- 4 weeks and 3 days)?

    select dateadd(day, -3, dateadd(week,-4,getdate()));

    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: Is this is the Best Practice to select E: for the SQL Server root directory?

    Sqlism (3/11/2013)


    Hi Experts,

    Is this is the Best Practice to select E: for the SQL Server root directory? Please let me know the Pros/cons and the practices to be followed.

    Thanks a...

    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: maximum rows without duplication

    Maybe code below will do what you need.

    I haven't tried for efficiency, just to get the result you want.

    select

    a.a, a.b, a.c

    from @a a

    left outer join (

    ...

    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: How to update same record that fires trigger?

    opc.three (3/8/2013)


    btio_3000 (3/8/2013)


    But wouldn't it create a recursive call on that trigger? Updating the same table that the UPDATE trigger is defined on?

    Thank you

    No, not unless RECURSIVE_TRIGGERS is ON. 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: Need guidance on how to Insert a new record between existing records

    Hmm, seems to me that in this case the query is the same either way, with exactly the same WHERE clause structure.

    The only difference is that the WHERE comparison value,...

    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: How to update same record that fires trigger?

    Sure, that's easy, as long as you have unique column(s), such as an IDENTITY column, you can use to identify a specific row in the table. SQL provides a...

    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: Just accepted a Sr. DBA job. Time for a gut check?

    Lynn Pettis (3/7/2013)


    ScottPletcher (3/7/2013)


    Sorry, not to rain on the parade, but to me now is not the time to celebrate.

    Getting the job is good, but it's just the start. ...

    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: Just accepted a Sr. DBA job. Time for a gut check?

    Sorry, not to rain on the parade, but to me now is not the time to celebrate.

    Getting the job is good, but it's just the start.

    Dedicate yourself to...

    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: Formatting issue in SQL

    Gazareth (3/7/2013)


    ScottPletcher (3/6/2013)


    To confirm, try writing the results returned by OBJECT_DEFINITION() to an nvarchar(max) column and checking the length of that column: I think you'll find that the entire 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: Hidden Tricks To SQL Server Table Cleanup

    SAinCA (3/6/2013)


    @ScottPletcher

    Not sure if what you are saying is that "it didn't happen the way I said it did..."

    READ_COMMITTED_SNAPSHOT isolation is set ON for the database in question.

    In order to...

    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,661 through 6,675 (of 7,613 total)