Forum Replies Created

Viewing 15 posts - 5,281 through 5,295 (of 7,619 total)

  • RE: Query running very slow

    pwalter83 (3/25/2015)


    ScottPletcher (3/25/2015)


    You should get rid of the DISTINCT in the subquery; since you're GROUPing on BL_ID, you don't need it anyway.

    Otherwise it's difficult to re-write because there are no...

    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: Elegant way for returning all results when subquery returns no results?

    If I understand the query correctly, I think this will do it:

    DECLARE @SearchId INT = 100

    SELECT Customer.*

    FROM Customer

    WHERE

    NOT 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: Query running very slow

    You should get rid of the DISTINCT in the subquery; since you're GROUPing on BL_ID, you don't need it anyway.

    Otherwise it's difficult to re-write because there are no aliases on...

    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: Want to return character(s) after a dash (-)

    You can specify a longer length on the SUBSTRING and it won't hurt anything, so you skip calculating the length; for example:

    SELECT SUBSTRING(string_value, CHARINDEX('-', string_value) + 1, 100)

    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: Good, free, simple database modelling tools

    CA ERwin has a free tool now, although that version does limit the number of objects. The full ERwin is a fantastic modeling tool (my favorite of the many...

    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: Design Question to minimize blocking

    The READPAST hint is very helpful in those types of situations. I believed it was designed to help handle these types of "queue assignment" 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: Creating multiple copies of a database.

    Detach can get messy, esp. with the file security changes that occur.

    I'd just restore the backup 20 times. You could bundle the entire process into a master job and...

    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: Unique Index

    Alexander Suprun (3/20/2015)


    ScottPletcher (3/20/2015)


    You'll want to explicitly state the FILLFACTOR and the filegroup, at least, rather than accept whatever the defaults happen to be:

    CREATE UNIQUE NONCLUSTERED INDEX <index name>

    ON...

    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: Cross Apply error

    I think you can do it by running from master and explicitly specifying the actual db name in the query:

    use master

    select *

    FROM your_db_name.dbo.Registos r

    CROSS APPLY your_db_name.dbo.fnObtemCategoriaAviacao(r.PaisOrigem, r.PaisDestino)

    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: <> and = in where clause

    Note that the original query and the new query will produce different results if the column can contain NULLs. You need to construct your final query to handle 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: Unique Index

    You'll want to explicitly state the FILLFACTOR and the filegroup, at least, rather than accept whatever the defaults happen to be:

    CREATE UNIQUE NONCLUSTERED INDEX <index name>

    ON <Table Name> (...

    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: Rebuild index

    Shrink does not always fragment indexes; it certainly does not always fragment every index. You can shrink as much as you really need and then rebuild/reorg any index that...

    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 left join

    siggemannen (3/19/2015)LEFT JOIN can at least in theory lead to duplicates of data potentially returned if you mess up the WHERE condition

    Not in the specific case where you're only looking...

    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: Read Committed Snapshot.

    Readers don't block writers, and writers don't block readers. Without RCS on, they do. This is a wonderful option, but it comes with a fairly high overhead cost,...

    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 left join

    ichayan2003 (3/19/2015)


    Thanks SScrazy for your input on this. But i am trying to avoid Is Null as there is a chance for null value on my tables.

    As GilaMonster suggests, i...

    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 - 5,281 through 5,295 (of 7,619 total)