Forum Replies Created

Viewing 15 posts - 316 through 330 (of 7,619 total)

  • Reply To: Can you reference 'Inserted' or 'Deleted' Trigger Table in SQL Mail Query

    The inserted and deleted "tables" only exist within the direct code of a trigger.  You can't reference them from an external query.  You'd need to write the inserted and deleted...

    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: Newby - Stuck with a trigger.

    This is somewhat confusing, but something like this would likely do what you want to do:

    SET ANSI_NULLS ON;
    SET QUOTED_IDENTIFIER ON;
    GO
    CREATE TRIGGER [dbo].[tr_ORDERID]
    ON [dbo].[MYCUSTOMERS]
    AFTER UPDATE
    AS
    SET NOCOUNT ON;
    BEGIN
    IF UPDATE(ORDERID)
    BEGIN
    ...

    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: sql command written in cmd that is .bat file is synchronous or asynchronous

    synchronous

    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: Scheduling SQL Agent Jobs on Alternating Weeks

    Code only needs to be schedule on the first and last Thursday of the month, since those are the only 2 days it might need to do something.

    As to simplification,...

    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: Scheduling SQL Agent Jobs on Alternating Weeks

    Jeff Moden wrote:

    ildjarn.is.dead wrote:

    The worst schema I had to implement: A customer wanted us to reboot the server for patches on the first friday of the month around 1am.

    How do 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 find second position after decimal

    (Dup post, removed)

     

    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 find second position after decimal

    ;WITH cte_data AS (
    SELECT CAST(50.10 AS numeric(5, 2)) AS HRS
    UNION ALL
    SELECT 50.77
    )
    SELECT HRS
    FROM cte_data
    WHERE HRS...

    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: Convert Old School to current ANSI/ISO SQL Standards

    LineCount must exist in your table, not the system table; if so, then change the alias before the column name:

    ...

    INSERT INTO dbo.PrimaryHist

    SELECT 'UPDATE'

    ,s.login_name

    ,i.batch_id

    ,i.LineCount --<<--

    FROM INSERTED AS i

    CROSS JOIN sys.dm_exec_sessions AS...

    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: Decrease size of database that is over 400 gb

    Page compression is generally very effective at reducing data size.  But you will need to either: (1) shrink the data file after compressing, which will take a long time and...

    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: Convert Old School to current ANSI/ISO SQL Standards

    That's the equivalent of a CROSS JOIN:

    SELECT 'UPDATE'
    ,s.login_name
    ,i.batch_id
    FROM INSERTED AS i
    CROSS...

    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: Find a word from string

    Or, just in case there might be: '64.0 MB,restricted growth to 2097152.0 MB'

    SELECT * FROM #tbl_datafile_list WHERE Autogrow LIKE '%[^A-Za-z]restricted[^A-Za-z]%'

     

    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: Trigger to track changes

    Triggers don't necessarily suck at performance, it depends on how they are written.  Neither does CDC perform all that poorly; in fact, I think it's extremely unlikely you could write...

    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: Query to find latest full backup with all database except tempDB

    ;WITH cte AS (
    SELECT @@SERVERNAME AS ServerName,
    ISNULL(b.database_name, d.name) AS DatabaseName,
    ...

    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: Avoiding Conversion errors

    Or make the value column a sql_variant data type.

    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: Avoiding Conversion errors

    SQL may not evaluate things in the order you expect it to, so something like that could indeed be happening in certain circumstances.

    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 - 316 through 330 (of 7,619 total)