Forum Replies Created

Viewing 15 posts - 4,006 through 4,020 (of 7,613 total)

  • RE: Create incrementing group numbers for groups of 500 rows?!

    I think the batch number would be:

    1 + ((row_number() over (order by custnum) - 1) / 500)

    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 parse numbers out of text string

    Maybe something like this?:

    select textid, textline,

    SUBSTRING(textline, percent_byte - length_of_percent + 1, length_of_percent) as percent_amount

    from #T

    cross apply (

    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: Using Large Integer Or GUID Vs Using Small Integers For Primary Key

    Jeff Moden (12/28/2016)


    ScottPletcher (12/28/2016)


    Then you encode the actual BankAccount value into a related int, as I stated above. That value initially could be gotten from an identity column in...

    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: Using Large Integer Or GUID Vs Using Small Integers For Primary Key

    Jeff Moden (12/27/2016)


    ScottPletcher (12/27/2016)


    How do you query that table, and how does it join to other tables? If it's by BankAccount, then definitely cluster by BankAccount value. If...

    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: Using Large Integer Or GUID Vs Using Small Integers For Primary Key

    How do you query that table, and how does it join to other tables? If it's by BankAccount, then definitely cluster by BankAccount value. If you need 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: Unique Indexes With Multiple Keys

    100% agree. Definitely define as index as "UNIQUE" whenever possible.

    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

    Jeff Moden (12/26/2016)


    Sergiy (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 =...

    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: Using Mod to Generate Work Shifts

    Here's the in-line code, hopefully it's trivial to convert it to an itvf once its logic has been verified:

    DECLARE @baseDate DATETIME = '1/1/2006 07:00:00';

    SELECT

    @baseDate AS...

    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: Index with leading BIT column

    If the flag is significant enough, make it the first column in the clustered index. For example, in a 90%-10% situation where you mostly process the 10%.

    Be aware 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: 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".

Viewing 15 posts - 4,006 through 4,020 (of 7,613 total)