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

  • Home
  • SEARCH
  • 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 7984873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:24:30+00:00 2026-06-04T11:24:30+00:00

My sql server database has this stored procedure… ALTER PROCEDURE [dbo].[NewBudget] @year int, @int

  • 0

My sql server database has this stored procedure…

ALTER PROCEDURE [dbo].[NewBudget]
@year int,
@int nvarchar(3)
AS
BEGIN
SET NOCOUNT ON;
INSERT [NAOLI].[dbo].[BudgetsEditTbl]
([F_Year],[O_OrgCode],[O_OrgDesc],[S_SubObject],[S_SubDescrip],[B_BudgetAmt],[B_Initials],[B_CIPrefNo],[B_OrgBudgetAmt],[keyfield]) 
SELECT @year as [F_Year],[O_OrgCode],[O_OrgDesc],[S_SubObject],[S_SubDescrip], 0.00 as [B_BudgetAmt],@int as [B_Initials],null as [B_CIPrefNo],null as [B_OrgBudgetAmt],NewID()
FROM [NAOLI].[dbo].[BudgetsEditTbl]
END

What happends is according to the parameter ‘@year’ it automatically updates the database with records for the new year on the year change. Only instead of updating it with the new year, the orgcode and the corresponding subobject it gives me 6 records with the same orgcode. So it is essentially running the procedure 6 times and storing all that mess in my database. Any idea how I can fix this problem?

2011 | 536003 | Engineering | 6302 | Roads and Components | 0.00 | MC | N/A | 0.00    
2011 | 536003 | Engineering | 6303 | Rights of Way -Acquire | 0.00 | MC | N/A | 0.00
2010 | 536003 | Engineering | 6302 | Roads and Components | 18300.00 | FG | N/A | 0.00    
2010 | 536003 | Engineering | 6303 | Rights of Way -Acquire | 18300.00 | FG | N/A | 0.00

So for each year the same codes and info go in just different amounts…

  • 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-04T11:24:31+00:00Added an answer on June 4, 2026 at 11:24 am

    You can use DISTINCT to remove any duplicates

    ALTER PROCEDURE [dbo].[NewBudget]
    @year int,
    @int nvarchar(3)
    AS
    BEGIN
    SET NOCOUNT ON;
    INSERT [NAOLI].[dbo].[BudgetsEditTbl]
    ([F_Year],[O_OrgCode],[O_OrgDesc],[S_SubObject],[S_SubDescrip],[B_BudgetAmt],[B_Initials],[B_CIPrefNo],[B_OrgBudgetAmt],[keyfield]) 
    SELECT DISTINCT @year as [F_Year],[O_OrgCode],[O_OrgDesc],[S_SubObject],[S_SubDescrip], 0.00 as [B_BudgetAmt],@int as [B_Initials],null as [B_CIPrefNo],null as [B_OrgBudgetAmt],NewID()
    FROM [NAOLI].[dbo].[BudgetsEditTbl]
    END
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SQL Server 2008 database. This database has a stored procedure that
I have a stored procedure on a SQL Server 2005 database which has a
I'm working on a SQL Server 2008 database. This database has two tables. Book
I have a database on a SQL Server 2000 server. This database has a
My Sql Server database has some nullable nvarchar fields, and no nvarchar fields containing
We have a SQL Server 2008 database that has stored procedures to handle reads/writes/etc.
I have an application on a SQL Server 2008 database. This database has a
I have a SQL Server database which has grown to more than 15GB in
I have a SQL Server 2005 database that has been deleted, and I need
The script to setup up the SQL Server database for Elmah has a warning

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.