Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8312845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:17:47+00:00 2026-06-08T20:17:47+00:00

A MS SQL insert trigger causes some grief as it returns a result. Is

  • 0

A MS SQL insert trigger causes some grief as it returns a result. Is there a way to disable any result from being sent? I’ve used ‘set nocount on’, but that doesn’t seem to do much…

create trigger tr_insert_raw_data
on raw_data
instead of insert
as
begin
 set nocount on

 declare @query varchar(max);
 declare @rev int;
 declare @id int;
 declare @oldrev int;
 declare @contextinfo VARBINARY(128)  

 select @contextinfo = context_info()
 if @contextinfo = 0x00001
 begin
  insert into raw_data select * from inserted
  return
 end

 select * into #query from inserted
 set @id = (select count(distinct id) from raw_data);
 set @id += 1;
 insert into revisions (username, hostname, ts) values (SYSTEM_USER, HOST_NAME(), GETDATE())
 set @rev = (select max(id) from revisions);

 select @oldrev = revision_id from inserted;
 if @oldrev is null set @oldrev=@rev-1;

 select * into #inserted from inserted
 update #inserted set revision_id = @rev, id = @id
 select * from #inserted
 insert into raw_data select * from #inserted
 insert into edges (a, b) values (@oldrev, @rev)
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T20:17:49+00:00Added an answer on June 8, 2026 at 8:17 pm

    what kind of a result are you getting?
    After a quick review of your query my first thought is that you’re getting results due to the

    select * from #inserted
    

    line you have (third line from bottom). This line tells me that you are requesting results which is probably why you’re getting some?

    If you do need values selected from a table to modify or custom select out of, perhaps CTE’s will help you out? (Common Table Expressions)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a trigger in SQL Server after INSERT, UPDATE and DELETE. Is there
In MS SQL Server 2008 R2, we want a pre-insert and pre-update trigger which
I need to perform a very large sql server insert from a c# application.
I am coding SQL Server 2005 trigger. I want to make some logging during
I am trying to create a simple insert trigger from Products table to ProductPrice
I have data coming in from datastage that is being put in our SQL
I have a view that has an INSTEAD OF INSERT trigger (in SQL Server
I'm new to SQL and I'm trying to create a trigger that would insert
SQL Server 2005+ I have a view with an INSTEAD OF INSERT trigger. Inside
I am doing a SQL Insert to populate my table. I have a unique

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.