Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Trggier not working with insert

Trggier not working with insert

Scheduled Pinned Locked Moved Database
databasecomtools
2 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    issam mansour
    wrote on last edited by
    #1

    Hi, I have an insert command saved to a table in a database "after insert" the trigger take the insert command and execute it. when the trigger execute it save the tweet in a second table on the in the same database and it work fine but the trigger in the second table does not work at all. following are the trigger and the table's:-

    Command Insert
    SET QUOTED_IDENTIFIER OFF
    SET ANSI_NULLS ON
    INSERT INTO [jbmolver].[dbo].[all_tweets] ([set_str],[name]) VALUES
    ("INSERT INTO [jbmolver].[dbo].[Twitter_Feeds] ([Twitter_ID],[Feed_ID],[Twitter_Date],[screen_name],[Author_Details],[Author_Email],[Author],[Sentiment],[sdate],[edate],[keyword],[type],[ncount],[latitude],[longitude],[radius],[lang],[friends_count],[followers_count],[following],[statuses_count],[location],[time_zone],[description],[in_reply_to_status_id],[in_reply_to_user_id],[in_reply_to_screen_name],[Rcounter],[address],[Feed_From_SM],[profile_image],[current_user_retweet],[withheld_scope],[retweet_count],[favourites_count],[url_type],[hashtags],[expanded_url]) VALUES ('933231091967778816','799796908478894080','2017-11-22 09:10:05',N'prettyraebae',N'Sis it s almost 2018 😭 https://twitter.com/babydrii\_/status/933230970412683264', '', 'Rae', '1', '', '', '', 'photo', '', '', '', '', 'en', '461', '737', '', '12503', '', '', N'UGA 20 ❤️', '', '', '', '0', '$', '2', 'http://pbs.twimg.com/profile\_images/867998936388313089/2Zdl5P2-\_normal.jpg', '0', '0', '0', '27988', '', '', '')", 'Twitter_Feeds')

    Table No. One:
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[all_tweets](
    [id] [int] IDENTITY(1,1) NOT NULL,
    [set_str] [nvarchar](max) NULL,
    [name] [nchar](30) NULL,
    CONSTRAINT [PK_all_tweets] PRIMARY KEY CLUSTERED
    (
    [id] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
    GO

    Trigger on Table One:

    /****** Object: Trigger [dbo].[exec_Update] Script Date: 11/23/2017 5:09:00 AM ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER TRIGGER [dbo].[exec_Update] on [dbo].[all_tweets]
    AFTER INSERT
    AS
    BEGIN
    declare @id int = 0
    set @id = ( select top 1 id from inserted )
    exec [dbo].[execute_all_tweets] '[dbo].[all_tweets]','[set_str]',@id
    END

    Table Number Two
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    SET ANSI_PADDING ON
    GO
    CREATE TABLE [dbo].[Twitter_Feeds](
    [id] [int] IDENTITY(1,1) NOT NULL,
    [Twitter_ID] [bigint] NOT NULL CONSTRAINT [DF_Twitter_Feeds_Twitte

    Richard DeemingR 1 Reply Last reply
    0
    • I issam mansour

      Hi, I have an insert command saved to a table in a database "after insert" the trigger take the insert command and execute it. when the trigger execute it save the tweet in a second table on the in the same database and it work fine but the trigger in the second table does not work at all. following are the trigger and the table's:-

      Command Insert
      SET QUOTED_IDENTIFIER OFF
      SET ANSI_NULLS ON
      INSERT INTO [jbmolver].[dbo].[all_tweets] ([set_str],[name]) VALUES
      ("INSERT INTO [jbmolver].[dbo].[Twitter_Feeds] ([Twitter_ID],[Feed_ID],[Twitter_Date],[screen_name],[Author_Details],[Author_Email],[Author],[Sentiment],[sdate],[edate],[keyword],[type],[ncount],[latitude],[longitude],[radius],[lang],[friends_count],[followers_count],[following],[statuses_count],[location],[time_zone],[description],[in_reply_to_status_id],[in_reply_to_user_id],[in_reply_to_screen_name],[Rcounter],[address],[Feed_From_SM],[profile_image],[current_user_retweet],[withheld_scope],[retweet_count],[favourites_count],[url_type],[hashtags],[expanded_url]) VALUES ('933231091967778816','799796908478894080','2017-11-22 09:10:05',N'prettyraebae',N'Sis it s almost 2018 😭 https://twitter.com/babydrii\_/status/933230970412683264', '', 'Rae', '1', '', '', '', 'photo', '', '', '', '', 'en', '461', '737', '', '12503', '', '', N'UGA 20 ❤️', '', '', '', '0', '$', '2', 'http://pbs.twimg.com/profile\_images/867998936388313089/2Zdl5P2-\_normal.jpg', '0', '0', '0', '27988', '', '', '')", 'Twitter_Feeds')

      Table No. One:
      SET ANSI_NULLS ON
      GO
      SET QUOTED_IDENTIFIER ON
      GO
      CREATE TABLE [dbo].[all_tweets](
      [id] [int] IDENTITY(1,1) NOT NULL,
      [set_str] [nvarchar](max) NULL,
      [name] [nchar](30) NULL,
      CONSTRAINT [PK_all_tweets] PRIMARY KEY CLUSTERED
      (
      [id] ASC
      )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
      ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
      GO

      Trigger on Table One:

      /****** Object: Trigger [dbo].[exec_Update] Script Date: 11/23/2017 5:09:00 AM ******/
      SET ANSI_NULLS ON
      GO
      SET QUOTED_IDENTIFIER ON
      GO
      ALTER TRIGGER [dbo].[exec_Update] on [dbo].[all_tweets]
      AFTER INSERT
      AS
      BEGIN
      declare @id int = 0
      set @id = ( select top 1 id from inserted )
      exec [dbo].[execute_all_tweets] '[dbo].[all_tweets]','[set_str]',@id
      END

      Table Number Two
      SET ANSI_NULLS ON
      GO
      SET QUOTED_IDENTIFIER ON
      GO
      SET ANSI_PADDING ON
      GO
      CREATE TABLE [dbo].[Twitter_Feeds](
      [id] [int] IDENTITY(1,1) NOT NULL,
      [Twitter_ID] [bigint] NOT NULL CONSTRAINT [DF_Twitter_Feeds_Twitte

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      Seems like a bad design, but here's the setting you need to change: Configure the nested triggers Server Configuration Option | Microsoft Docs[^]


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups