Forum Replies Created

Viewing 15 posts - 2,731 through 2,745 (of 7,613 total)

  • Reply To: using trigger for tracing

    An AFTER UPDATE trigger on the table would capture who, at least as well as you can within SQL Server.  You can use "UPDATE(column_name)" to limit it to only processing...

    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".

  • Reply To: Primary Key and Clustered Index

    If the AccountNumber must be changed, it will have to change whether it's the clustering key, and/or a PK, or not.

    In that situation, you'd temporarily disable FK checking as needed...

    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".

  • Reply To: odd error message in function in a proc

    You'd need to post the actual code that processes the cursor for us to really accurately help.

    But, likely an extra FETCH is being issued.  People insist on coding multiple FETCH...

    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".

  • Reply To: Primary Key and Clustered Index

    No, ID is absolutely not needed.  It's likely to hinder processing since people tend to inevitably cluster on it.

    Use the AccountNumber as the clustering key and the primary key.  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".

  • Reply To: Counting specific columns in a record where those columns rows are > 0

    To avoid any IF / CASE logic, I usually use this technique instead:

    SIGN(Jan) + SIGN(Feb) + ...

    In situations where the numbers could ever be negative, you'd need to include ABS()...

    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".

  • Reply To: ColumnStore Index - Rowgroup elimination - Inserting in Sort Order

    I would think so, since SQL doesn't (re)order / sort rows going into a columnstore, it loads them in the same order in which they arrive.

    Thus, presumably the first 1,048,576...

    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".

  • Reply To: Removing a Key Lookup

    Yeah, I was incorrectly thinking of column3 also matching.

    I don't like having to have duplicative indexes.  I'd probably go with just:

    ( column2, datetime ) INCLUDE ( column3 )

    Sure, that index...

    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".

  • Reply To: Removing a Key Lookup

    I would of that the best index would be:

    (Column3, Column2, DateTime)

    given the WHERE condition.

    Particularly if you later use the same query with:

    Where tab1.Column3= 9

    to query a different column.

    And I'd move...

    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".

  • Reply To: More performant way to write this where clause

    Since an IN gets converted to ... OR ... OR ..., I suppose it might make a difference, in which case you'd want to put the most common values first.

    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".

  • Reply To: how to modify 2 different sets with single query

    Technically, if j.Grp is NULLable, I think you'd need to use:

    WHERE j.Grp IS NOT NULL AND j.Code <> 'L3'

    to insure the same results as the original code.

    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".

  • Reply To: Need help with query where i need to aggregate an aggregate

    You waste space and risk ambiguity by storing dashes in a date?  Seriously?  If for some bizarre reason one insists on storing dates as char, they should be YYYYMMDD.  Unambiguous. ...

    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".

  • Reply To: Need help with query where i need to aggregate an aggregate

    I don't really have any issue with storing cc numbers as char(16), especially since they'll need to be encrypted and end up being stored as binary anyway.  I also wouldn't...

    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".

  • Reply To: Need help with query where i need to aggregate an aggregate

    Actually an identifier is numeric (integer) because it just makes no common sense to do otherwise.  Overly-pedantic concerns about whether it's used in math or not are actually irrelevant.  There...

    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".

  • Reply To: update table all 0 values to null single query

    Probably cleaner to check for 0 values as you INSERT the row:

    INSERT INTo #a

    select NULLIF(0,0),NULLIF(1,0),NULLIF(0,0),NULLIF(2,0)

    union ALL

    select NULLIF(0,0),NULLIF(2,0),NULLIF(0,0),NULLIF(3,0)

    union ALL

    select NULLIF(0,0),NULLIF(3,0),NULLIF(0,0),NULLIF(4,0)

    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".

  • Reply To: Mail when value of field < or > paramater%

    A trigger is actually perfect for this situation.  For the email, it's probably best to add row(s) to a table or queue, then construct and send the emails based 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".

Viewing 15 posts - 2,731 through 2,745 (of 7,613 total)