Forum Replies Created

Viewing 15 posts - 4,036 through 4,050 (of 7,613 total)

  • RE: ROW_NUMBER to distinguish between identical records

    First, the Project table should be keyed on ( DomainID, SchoolID, ID ), if, as your example query implies, Domain is the more dominant "parent" relation. Reverse the first two...

    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 duplicate keys

    Something like this should do it:

    IF OBJECT_ID('tempdb.dbo.#table2_data') IS NOT NULL

    DROP TABLE #table2_data

    --create the table structure for #table2_data

    SELECT TOP (0)

    Application,

    ...

    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: Grant access to user to run a SQL agent job

    You have a couple of choices.

    If you are willing to allow them to run any (local) job, you can add them to the SQLAgentOperatorRole in msdb.

    If you want them 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: advice on model

    Is this acceptable? No.

    Can this be improved? Yes.

    Most importantly, you do not need an identity column on two of these tables. Despite what some people may imply, there's no...

    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: SQL server not using Index when dates are used as variables as opposed to constants

    The real solution is very likely to cluster the table on event_date, if that is how you most often query the table. You'll get minimum I/O without having 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: Trigger Questions

    TheSQLGuru (11/8/2016)


    ScottPletcher (11/8/2016)


    It depends on how complex the trigger logic and how much different it is for each type of modification whether you want separate triggers or not.

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

  • RE: Trigger Questions

    It depends on how complex the trigger logic and how much different it is for each type of modification whether you want separate triggers or not.

    But you can definitely simplify...

    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 find all procedures that uses functions in the where clause(left operand)

    drew.allen (11/3/2016)


    ScottPletcher (11/3/2016)


    You could try limiting the pattern matching to only the text between "[whitespace-char]WHERE[whitespace-char]" and the next occurrence of "GROUP BY" or "SELECT". Of course that's also 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: update question

    drew.allen (11/3/2016)


    ScottPletcher (11/3/2016)


    I avoid the ISNULL "tricks" when I can in favor of straightforward code:

    UPDATE table_name

    SET Foo = CASE WHEN Foo > '' THEN ', ' ELSE '' END +...

    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: Remove decimal from varchar field

    J Livingston SQL (11/3/2016)


    ScottPletcher (11/3/2016)


    SELECT

    SD.NUMBERS

    ,RIGHT('0000000' + REPLACE(NUMBERS, '.', ''), 7)

    FROM SAMPLE_DATA SD;

    which I believe is what...

    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 find all procedures that uses functions in the where clause(left operand)

    You could try limiting the pattern matching to only the text between "[whitespace-char]WHERE[whitespace-char]" and the next occurrence of "GROUP BY" or "SELECT". Of course that's also not perfect, but...

    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: Remove decimal from varchar field

    SELECT

    SD.NUMBERS

    ,RIGHT('0000000' + REPLACE(NUMBERS, '.', ''), 7)

    FROM SAMPLE_DATA SD;

    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 question

    I avoid the ISNULL "tricks" when I can in favor of straightforward code:

    UPDATE table_name

    SET Foo = CASE WHEN Foo > '' THEN ', ' ELSE '' END + 'newvalue'

    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: Tunning the Query

    Sorry, don't have a lot of time, but here's my best guess at what could help:

    SELECT i.Item_ID AS Kit_SID

    , i.Item_ID AS Kit_ID

    , i.Item_NO AS Kit_NO

    ...

    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: Risks of Updating to another edition

    You would at least have to remove anything that used a feature available in Enterprise Edition that's not also available in Standard Edition. No compressed tables, etc..

    But once...

    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,036 through 4,050 (of 7,613 total)