Forum Replies Created

Viewing 15 posts - 6,466 through 6,480 (of 7,613 total)

  • RE: Triggers on Tables

    I think DISABLE is far more dangerous, since it applies to every task modifying the table.

    Instead you can use CONTEXT_INFO to selectively exit the trigger / skip all/part of 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: Trying to iteratively use PATINDEX commands to comb through a large amount of text

    The code uses LIKE to compare the string, so just construct your string accordingly.

    For example, you could use 'ls-' as the search string. Or, if you want a closer...

    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: Identify string or integer

    EXEC Stored_procedure1 ('abc')

    EXEC Stored_procedure1 ('123')

    EXEC Stored_procedure1 ('abc112')

    Yes. The core of the logic is this:

    CASE WHEN <string_value> LIKE '%[^0-9]%' THEN <string> ELSE <int> END

    For example:

    SELECT

    data,

    ...

    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: Triggers on Tables

    cdl_9009 (8/14/2013)


    Is there a way to turn a table trigger off in a stored procedure, then turn it back on after it skips that table.

    We have the trigger in place...

    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 JOBS

    Assuming the account running "JobA" has the authority to start jobB, the command in JobA would be:

    EXEC msdb.dbo.sp_start_job 'JobB'

    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: Trying to iteratively use PATINDEX commands to comb through a large amount of text

    That code's written for SQL 2000; I suggest completely ignoring it.

    Instead, the code below should give you a list of object names and their full text reasonably quickly.

    If you want...

    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: Date incrementing

    Extremely vague, but perhaps:

    DATEDIFF function

    DATEADD function

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

  • RE: Differential backup

    Typically:

    .dif = differential backup

    .fil = filegroup backup

    .trn = tranlog backup

    as most people follow MS's lead, as they did with .bak, .mdf, .ndf (silly, imo, why not .mdf also???), etc..

    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 Group by the Past Seven Days

    garyh2k3 (8/13/2013)


    My spreadsheet has sample data of grouped by month, grouped by Day. I would like the same date displayed for the group by the past 7 days. ...

    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: Can a table have two primary keys?

    seshu67 (8/7/2012)


    Can a table have two primary keys

    Absolutely no, period. The fact that separate unique constraints can be defined does not make them primary keys as well.

    Similarly, a table...

    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 help - summing between dates ranges and calculations...

    Stefan_G (8/9/2013)


    Easy enough to change the WHERE on the date to an OR with the two specific date ranges.

    If the @StartDate is the start of the current period -- which...

    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: Restore the mdf from a BAK to multiple drives possible?

    You can't do it as part of the restore. You could do it after it was restored, but it would involve some serious effort though.

    Maybe you could instead restore...

    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: Reset identity seed on a large table

    SQL has a command to do that directly:

    DBCC CHECKIDENT ( <table_name>, RESEED, <new_reseed_value> ) --WITH NO_INFOMSGS

    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: Help with the query and index.

    Hmm, interesting. SQL's still "dumber" than I thought :-).

    We'll need to UNION the query results instead of using "OR".

    Also, as always, we want the variable to be exactly 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: Find number in String and Return INT

    You might want to allow for no comma being in the string (just in case).

    And you can remove some unnecessary elements from the code:

    SELECT CAST(LEFT(@buyer, CHARINDEX(',', @buyer + ',') -...

    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 - 6,466 through 6,480 (of 7,613 total)