Forum Replies Created

Viewing 15 posts - 4,021 through 4,035 (of 7,619 total)

  • RE: When Your Primary Key is Not the Clustered Index

    m.sams (12/16/2016)It seems to me that one could remove the primary key index and create a new unique non-clustered index and then add the necessary include columns and have 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: Will Cancelling an update that updates 50k rows in a while loop rollback id cancelled

    No, not unless you have an explicit BEGIN TRANSACTION outside of that code. By default, each statement is automatically committed once it completes.

    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: Bitwise & NULL

    Sioban Krzywicki (12/15/2016)


    ScottPletcher (12/15/2016)


    Pretty soon you'll see in queries "WHERE Status&8 >0".

    I guess I don't see why that's so much worse than a non-bit comparison of "status = 8"...

    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: Bitwise & NULL

    Pretty soon you'll see in queries "WHERE Status&8 >0".

    I guess I don't see why that's so much worse than a non-bit comparison of "status = 8" or "code1 =...

    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: NULL Datetime causing NULL string when converting

    I'll offer a "template" approach just as a possible alternative. Often I find it easier because I get a better visualization of the desired result up front than 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 to join three tables but filter out subset of the data

    CELKO (12/13/2016)


    It wouldn't be SSN, because (1) that can change and (2) it might not technically be legal in certain use cases for a private company to use that.

    Yes,...

    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: Bitwise & NULL

    You could also have another table that documented the bit value meanings. Here's a quick-and-dirty example, would obviously need fleshed out quite a bit more:

    CREATE TABLE dbo.bit_values_master (

    ...

    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 join three tables but filter out subset of the data

    CELKO (12/13/2016)

    Obviously in a real schema, the identifier of an employee would be some sort of industry-standard encoding (Social Security number in the United States, social insurance number in Canada,...

    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: Bitwise & NULL

    I see some strong advantages to the combined-bits approach.

    To distinguish NULL values, I think you'd need another column of the same int type, with bits in it to indicate NULL...

    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: Data update

    You still don't need to cast the column, so why get into that bad habit? Yes, SQL corrects it in this case (at least for now?!). Why not...

    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: trying to get rid of clustered index scan

    Create the index below. Uncomment anything you can:

    CREATE /*UNIQUE*/ NONCLUSTERED INDEX AdminObservation__IX_TherapyAdmin_ID

    ON hcs.AdminObservation ( TherapyAdmin_ID )

    INCLUDE ( VisitObservation_ID )

    ...

    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 querying dates and times

    ...

    WHERE datetime_column >= @StartDate_set_to_0800_AM AND

    datetime_column < DATEADD(DAY, 1, @EndDate_set_to_midnight) AND

    DATEPART(HOUR, datetime_column) BETWEEN 8 AND 16

    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: Kill SPIDs through automated job(while restore)

    Personally I've had much lesser delays/stalls using this command:

    ALTER DATABASE SQLTRIX SET OFFLINE WITH ROLLBACK_IMMEDIATE;

    And you can get into devilish issues with "SINGLE_USER". You need to make sure 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".

  • RE: Last 2 years and YTD

    Double oops, you're right. I made sure, too, that I went back to Jan 1 00:00 to get the full year.

    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: Last 2 years and YTD

    Oops, right, YEAR - 3 not YEAR - 2.

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