Forum Replies Created

Viewing 15 posts - 4,246 through 4,260 (of 7,619 total)

  • RE: Reducing the hash match inner join cost

    If the "isactive" flag is significant, i.e. a significant number of rows are actually inactive, then cluster first on it. If not, get rid of it. At 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".

  • RE: UNIQUE Constraint Help please

    You could use a standard unique constraint if you continually deleted searches 2 hours or more old from the table. For example, have a job that deletes rows every...

    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: Rounding datetime to midnight

    The "standard/best-practice" way to get yesterday's date is:

    DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()) - 1, 0)

    Based on that, then make the necessary 6-hour adjustment on the starting time [the "+" in 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".

  • RE: Allowing a user to run a Job

    While logged in as sysadmin, create a stored proc that includes "WITH EXECUTE AS OWNER". In that proc, have the command:

    EXEC msdb..sp_start_job @job_name = @job_name, ...

    Then GRANT the role(s)/user(s)...

    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: Not a DBA admin - How do i optimize/tune my queries, check on missing index?

    To do any proper type of index tuning, you must have access to at least:

    missing index stats, via sys.dm_db_missing* views;

    index usage stats, via sys.dm_db_index_usage_stats;

    index operational stats, via sys.dm_db_index_operational stats.

    With 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: Aggregating Correlated Sub-Queries

    I don't think the need the GROUP BY on the outer query, just a SUM() OVER(), so maybe this?:

    SELECT

    f.Country

    ,f.CompanyName

    ,f.InvoiceID

    ,f.SupplierCode

    ,f.InvoiceNumber

    ,f.[Scan Date]

    ,f.[Approval Date]

    ,f.[Days to Final Approval]

    ,f.[<7 Days]

    ,f.[>7 Days]

    ,SUM([>7 Days]) OVER(PARTITION BY f.Country...

    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: Restoring 100s of user databases..

    You really do need a stored proc, given how complex the restore process could be, with a full backup, maybe differential, maybe log file(s).

    I have a special user/utility db 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: Split AlphaNumeric

    Assuming you want to split first by a space, but if there's no space then by dash:

    SELECT value, LEFT(value, ISNULL(NULLIF(CHARINDEX(' ', value), 0), CHARINDEX('-', value) - 1)) AS split_value

    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: SP with 3 parameters as delimited list - Goal 500 milliseconds

    If you:

    1) always, or

    2) almost always, or

    3) most critically

    search these tables using RECORD_TYPE_CD, as in this query, then you should cluster those tables first on RECORD_TYPE_CD. 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: SP with 3 parameters as delimited list - Goal 500 milliseconds

    If you:

    1) always, or

    2) almost always, or

    3) most critically

    search these tables using RECORD_TYPE_CD, as in this query, then you should cluster those tables first on RECORD_TYPE_CD. 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: Concatenate strings

    Jeff Moden (7/1/2016)


    ScottPletcher (7/1/2016)


    I still say don't explicitly code it unless the code requires it (some system procs require unicode strings specifically, for example), because it can cause performance...

    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: Concatenate strings

    Jeff Moden (7/1/2016)


    Agreed... and the catch here is that if this happens, what else could happen? If you use the "N" prefix for the literals whenever NVARCHAR is used,...

    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: Concatenate strings

    Sergiy (6/30/2016)


    ScottPletcher (6/30/2016)


    Jeff Moden (6/24/2016)

    Shifting gears a bit and depending on how that's used, it could become a performance problem due to the implicit conversions of the string literals. ...

    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: Concatenate strings

    Jeff Moden (6/24/2016)

    Shifting gears a bit and depending on how that's used, it could become a performance problem due to the implicit conversions of the string literals. Since @database2...

    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: Update 1 of 3 tables based on parameter

    Jeff Moden (6/28/2016)


    David92595 (6/28/2016)


    @jeff

    Because I inherited this database and the person that made it thought in spreadsheets not relational tables.

    @scott

    Thank you! Are their any other good ways to stop 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".

Viewing 15 posts - 4,246 through 4,260 (of 7,619 total)