Forum Replies Created

Viewing 15 posts - 5,686 through 5,700 (of 7,619 total)

  • RE: Rank duplicates, but only rows involved in duplicates

    jeff.born (10/22/2014)


    The solution with the min and max would work if there were only duplicates, but Businesses have been known to be duplicated 100s of times due to previous incorrectly...

    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: Rank duplicates, but only rows involved in duplicates

    SELECT

    [BusinessName], [Address], [Phone]

    ,MIN(Business_pk) AS Business_pk_min,

    ,MAX(Business_pk) AS Business_pk_max

    FROM [dbo].[TestBusiness] bus

    INTO [dbo].[DuplicateBusinesses]

    GROUP BY

    [BusinessName], [Address], [Phone]

    HAVING COUNT(*) > 1

    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: Get Sql Server Ageng Job Id from within a running job

    You should be able to use the session_id to do the lookup. But since session_ids are reused, and sysjobactivity keeps history, if your proc is not currently running 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: Replacing a CASE statement in an update with table-driven logic

    Frank The Tank (10/21/2014)


    Thanks for all of the responses. Lots of interesting ideas. The computed column approach is probably the most elegant, but it was met with 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: Replacing a CASE statement in an update with table-driven logic

    Phil Parkin (10/21/2014)


    ScottPletcher (10/20/2014)


    If the controlling column(s) are all from the same table, I suggest a computed column. That leaves the defining logic in only a single place, 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: Can I change colum width of varchar in production

    Increasing the size of a [n]varchar column isn't directly a problem.

    But, if you think people will go back and increase the length of those columns in a significant...

    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: Replacing a CASE statement in an update with table-driven logic

    If the controlling column(s) are all from the same table, I suggest a computed column. That leaves the defining logic in only a single place, and allows the calc'd...

    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 Help with Stored Procedure

    CELKO (10/20/2014)


    ..SEQUENCEs can "lose" numbers as well: if the transaction rolls back, the acquired sequence number(s) cannot be put back in the pool. If, by law, you can't have...

    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: Performance of 'OR' in a where clause

    I prefer EXISTS over NOT IN especially, since NULL values will prevent NOT IN from working. You might see if that also corrects the optimizer issue.

    select *

    from table_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: How does transaction rollback across multiple database

    Yes, all modifications to recoverable resources for a single transaction must either all fail or all work, never some and not others. This is fundamental to how SQL Server...

    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: Comparing two very large data sets - which join should i use?

    With that many rows, you'll probably want to consider other, more efficient methods of comparing tables.

    For example, change tracking would allow you to determine the rows in each table 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: How can I Prepend 2 CHAR in front of an INT?

    SELECTc.cust_fullname AS Name,

    c.cust_membership_id AS Account,

    t.c_amount AS Amount,

    'CH' + CAST(t.i_ticket_id AS varchar(12))...

    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: Case Statements and Performance

    In general, it is a good idea to create reference/lookup tables instead of using case statements for gains in performance?

    In general, for a limited number of values (say 10 or...

    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: Estimating index size before creating it

    My code to calculate max row length for a table -- and an index isn't that different -- shows 30 bytes, assuming 4 bytes for the clustering key.

    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: The instance of the SQL Server Database Engine cannot obtain a LOCK resource at this time.

    The index you need for that DELETE would be keyed on:

    ( pk_Source, pk_cession )

    If you only ever do this for pk_source = 2 (and not any other source numbers), you...

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