Forum Replies Created

Viewing 15 posts - 2,716 through 2,730 (of 7,613 total)

  • Reply To: Need help in building Query

    I guessed you would want to sort/order by Item first; if not, you might want to reverse the GROUP BY to Name, Item.

    SELECT Item, Name, 
    ...

    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: Adding tempdb files to triage miscongfigured tempdb

    Jeff Moden wrote:

    webrunner wrote:

    The server has a database that is several hundred GB in size, so it's amazing that the server is even running at all.

    Heh... while the world insists 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".

  • Reply To: Retention for SQL Error Log

    A bit tricky really, unless you want to take the 90 separate log files approach.

    For example, if you set a job to cycle the log every 15 days, then the...

    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: Issue with max() and aggregate, missunderstanding

    I recommend one simplification to make your SQL coding and maintenance easier: use "*" in the inner query using ROW_NUMBER().  SQL will still only actually retrieve the data that is...

    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: Adding tempdb files to triage miscongfigured tempdb

    I believe so.  Just use the standard SQL command to add a file(s):

    ALTER DATABASE tempdb ADD FILE

    ( NAME = ..., FILENAME = '...' , SIZE = nnnMB, ... ),

    ( NAME...

    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: JSON_VALUE in WHERE-clause results in error

    Worked on my SQL 2016 too.

    Just to be safe, add the N in front of the second literal:

    SELECT 1 WHERE JSON_VALUE( '{"id":"1","name":"me"}' , N'$.id' ) = '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".

  • Reply To: Update using Join to multiple Records - which one wins?

    As I understand it, if multiple matches are possible, SQL can match any row.  That is, the results are unknown and you should assume they are effectively random.

    Similarly, if 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: Displaying Checkbox Values and Best Data Structure

    I think a smallint would suffice for language code.  I can't imagine there being more than 64K languages (including negative values if absolutely necessary).

    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: Displaying Checkbox Values and Best Data Structure

    drew.allen wrote:

    ScottPletcher wrote:

    Typically one would use a bit value setting to reduce space usage.  For example:

    languages int NOT NULL

    You'd want a separate table with the language code values:

    CREATE TABLE #language_codes...

    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: dynamically crud operation wit one procedure for all tables

    Again, very bad idea trying to combine all three actions, even for one table, let alone for all tables.

    It's easy enough to generate individual procs.  If you wanted to, 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: Displaying Checkbox Values and Best Data Structure

    Typically one would use a bit value setting to reduce space usage.  For example:

    languages int NOT NULL

    You'd want a separate table with the language code values:

    CREATE TABLE #language_codes ( language_bit...

    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: dynamically crud operation wit one procedure for all tables

    I suppose you could force that to work, but it's a bad idea.  Individual tables have vastly different columns and requirements.

    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: sp_executesql with multiple parameters

    The major problem with your first query is that it doesn't satisfy the original conditions to: select all rows if the value is NULL.  Other than dynamic SQL, the scan...

    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: using trigger for tracing

    Of course bad triggers can be written.  Bad stored procedures can also be written, but that doesn't mean we should quit writing stored procedures (agreed?).   Yes, take great care 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".

  • Reply To: sp_executesql with multiple parameters

    Don't use functions in a WHERE clause if you can avoid it, as they destroy "sargability".

    In this case, just directly check each variable for NULL or a match, as below. ...

    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,716 through 2,730 (of 7,613 total)