Forum Replies Created

Viewing 15 posts - 4,816 through 4,830 (of 7,619 total)

  • RE: Query written by a beginner

    I don't see anywhere that the dbo.Company table is being used, so I removed it.

    I also removed the multiple JOINs, although I did not add a GROUP BY...

    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: Delete large number of records

    You could partition the table, but it's likely overkill in this situation. All you probably need is the best clustered index and only the nonclustered index(es) you actually need,...

    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: Delete large number of records

    There are two main reasons it's taking so long:

    1) no clustered index

    2) too many nonclustered indexes

    My best guess is that Trx_Date should be the clustered index. But we need...

    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: matainence jobs are failing

    I don't use MPs either.

    But check for missing dbs. For example, maybe a db was moved or renamed.

    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: ISNULL vs IS NULL performance

    There's a simple rule for this:

    NEVER use ISNULL() in a WHERE or JOIN clause.

    You can easily code around it, and it could cause performance issues. Even if there's 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: how to calculate dates difference in a same table

    SELECT first_appointment.*, next_appointment.*

    FROM (

    SELECT customer#, MIN(appoinment_date) AS appointment_date

    FROM table_name

    GROUP BY customer#

    HAVING MIN(appointment_date) >= '20140101'...

    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: First Occurance of the string from text

    You have at least one rule missing. For example, in

    Text1=

    'ABNAGENDRACSURENDRADJITHENDRAXNARENDRABVEERNDARAXDRMNDRAXRVINDRABNAGENDRACSURENDRADJITHEN'

    The first A not followed by a B, C or D is "AGENDR". Why is that "A" excluded?

    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: logging without blocking?

    tobe_ha (9/4/2015)


    ScottPletcher (9/4/2015)


    Does the log table have an identity column? Did you try removing that column and see if the table is still locked? Typically multiple tasks should...

    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 blank ('') in datediff function

    Jacob Wilkins (9/4/2015)


    Ah, thanks for posting that. I'd been having more trouble finding a 2008 instance than I'd expected.

    So it seems 2008 (not R2) is the same as the others...

    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: logging without blocking?

    Does the log table have an identity column? Did you try removing that column and see if the table is still locked? Typically multiple tasks should be able...

    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: Difference count

    You certainly don't need a calendar table for that simple a calculation! All you need is:

    SELECT (DATEDIFF(MONTH, 0, @enddate) / 3) - (DATEDIFF(MONTH, 0, @startdate) / 3) + 1

    declare...

    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 to return all rows from any table containing a value range in a specified column

    Hrothgar (9/4/2015)


    That's a very good and very helpful solution; very many thanks.

    As the results seem to come out in an arbitrary order, or at least in an order that 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".

  • RE: Get blank ('') in datediff function

    Jacob Wilkins (9/1/2015)


    ScottPletcher (9/1/2015)


    Jacob Wilkins (9/1/2015)


    ScottPletcher (9/1/2015)


    Jacob Wilkins (9/1/2015)


    I know it's rather off-topic, but it's an interesting diversion, so I thought I'd just chime in on NOLOCK and temporary tables.

    SELECT...

    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: Huge headache to work with big data

    I can't see the screenshot. A screenshot is pretty useless anyway. Actual text would be much better.

    But, in short, here's the approach I recommend:

    1) encode the large varchar...

    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 to return all rows from any table containing a value range in a specified column

    Lynn Pettis (9/3/2015)


    ScottPletcher (9/3/2015)


    Very busy at work, just now was able to complete the code. I'll go ahead and post it as an alternative. I prefer a "template"...

    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 - 4,816 through 4,830 (of 7,619 total)