Forum Replies Created

Viewing 15 posts - 1 through 15 (of 345 total)

  • RE: Triggers

    Change "<source_db>.dbo.tbl_Users" to "inserted" in the from clause and that should get what you want.

  • RE: 15 Quick Short Interview Questions Useful When Hiring SQL Developers

    dkrasnikov (2/28/2013)


    Re: #10

    Even with Technet article to "prove" it, you cannot use HAVING without GROUP BY clause.

    Sure you can, if you do it correctly:

    select count(AddressID)

    from Address

    having count(AddressID) > 1

  • RE: Problem Capturing Constraint Violations Using INSTEAD OF Trigger

    Issue a ROLLBACK in the trigger after the CATCH and before the INSERT.

  • RE: combining the results of multiple select statements in to a single row

    As a quick and dirty, I would do this:

    with counts as (

    select * from

    (select count (*) as Col1 from sys.columns where (column_id = 1)) x

    cross apply

    (Select Count (*) as...

  • RE: Weird Behavior of Trigger

    Mark-545947 (2/14/2013)


    toddasd (2/14/2013)


    So the trigger itself runs correctly from both sources. And there are no triggers on the tables BACK or BACK_RLFL. The only part left is the guts of...

  • RE: Weird Behavior of Trigger

    Mark-545947 (2/14/2013)


    Both SSMS and SSIS reported 1 record which is the correct result.

    What's next?

    So the trigger itself runs correctly from both sources. And there are no triggers on the tables...

  • RE: Weird Behavior of Trigger

    Mark-545947 (2/14/2013)


    No triggers anywhere else.

    It has to be some setting issue in SSIS otherwise, why would work from SSMS.

    This is driving me crazy.

    Take the BACK tables out of the equation....

  • RE: Weird Behavior of Trigger

    Mark-545947 (2/14/2013)


    I understand your point of trigger firing on batches and not on rows. Then why doesn't my trigger work when I insert into it ONE record (FROM SSIS).

    Here is...

  • RE: Weird Behavior of Trigger

    This makes more sense:

    CREATE TRIGGER [dbo].[ArchiveBACK] ON [dbo].[RLFL]

    AFTER INSERT

    AS

    SET NOCOUNT ON;

    INSERT INTO BACK_RLFL

    SELECT b.*

    FROM BACK b

    WHERE b.OrderID in (select i.OrderID from inserted i)

    GO

  • RE: Weird Behavior of Trigger

    Mark-545947 (2/14/2013)


    Sure it does for the situation of archiving what is not already there, but now you've introduced a new table, BACK_ARCHIVE. So I see four tables: BACK, RLFL, RLFL_BACK,...

  • RE: Weird Behavior of Trigger

    Mark-545947 (2/14/2013)


    That does not work.

    Sure it does for the situation of archiving what is not already there, but now you've introduced a new table, BACK_ARCHIVE. So I see four tables:...

  • RE: Weird Behavior of Trigger

    I was playing around with this, and came up with this as a pretty simple approach:

    ALTER TRIGGER [dbo].[ArchiveBACK] ON [dbo].[RLFL]

    AFTER INSERT

    AS

    SET NOCOUNT ON;

    INSERT INTO BACK_RLFL

    SELECT * FROM INSERTED ...

  • RE: combining the results of multiple select statements in to a single row

    Use cross apply, like so

    select * from

    (select count (*) as Col1 from sys.columns where (column_id = 1)) x

    cross apply

    (Select Count (*) as Col2 from sys.columns where (column_id = 2))...

  • RE: Please help my carrer Path?

    Sure, I'll help out.

    First, there is no need to capitalize random words in sentences. I can't tell if it is for emphasis or not, but either way, it's not...

  • RE: Changing from "hard-coded" to dynamic query

    Just initialize the string with that query, like so:

    Declare @loopYrbeg int

    Declare @loopYrend int

    Declare @tablename sysname

    Declare @sql varchar(MAX)

    Set @loopYrbeg = 2007

    Set @sql = 'select * from tableCurrent...

Viewing 15 posts - 1 through 15 (of 345 total)