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 9212421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:31:16+00:00 2026-06-18T01:31:16+00:00

My applications calls a stored procedure as required by my use case. The stored

  • 0

My applications calls a stored procedure as required by my use case. The stored procedure insert records into two tables related by primary and foreign key constraints.

This means PatientNumber in Visit table must exist in the Patient table.

When I debug this procedure no value is display after setting initial values.

I am new to this, please help.

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Add_Patient_Visit]
AS
BEGIN TRANSACTION
    SET NOCOUNT ON; 

    declare @Visit_Number Varchar(50)
    declare @Prescription_Number Varchar(50)
    declare @Visit_Date Datetime = GETDate()

    set @Visit_Number = '25684956555'
    set @Visit_Date = GETDATE()
    set @Prescription_Number = '653214658'

    INSERT INTO Visits(Visit_Number, Visit_Date, Patient_Number)
    VALUES(@Visit_Number, @Visit_Date, @Patient_Number)

    IF @@ERROR <> 0
    BEGIN 
        ROLLBACK
        RETURN
    END

    declare @Patient_Number Varchar(50)
    declare @FirstName Varchar(50)
    declare @LastName Varchar(50)
    declare @Trible Varchar(50)
    declare @Gender Varchar(5)
    declare @Date_Of_Birth Datetime

    INSERT INTO Patient(Patient_Number, FirstName, LastName, Tribe, Gender, Date_Of_Birth)
    VALUES (@Patient_Number, @FirstName, @LastName, @Trible, @Gender, @Date_Of_Birth)

   IF @@ERROR <> 0
   BEGIN
       ROLLBACK
       RETURN
   END

   COMMIT
GO
  • 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-18T01:31:17+00:00Added an answer on June 18, 2026 at 1:31 am

    There is a mistake in above procedure. You are using @Patient_Number before declaring, while inserting in table ‘Visits’. Declare it in begining, like :

    declare @Patient_Number Varchar(50)
    declare @Visit_Number Varchar(50)
    declare @Prescription_Number Varchar(50)
    declare @Visit_Date Datetime = GETDate()
    set @Visit_Number = '25684956555'
    set @Visit_Date=GETDATE()
    set @Prescription_Number='653214658'
    
    Insert into Visits(Visit_Number,Visit_Date,Patient_Number)
    Values(@Visit_Number,@Visit_Date,@Patient_Number)
    IF @@ERROR <> 0
    BEGIN 
    ROLLBACK
    RETURN
    END
    
    
    declare @FirstName Varchar(50)
    declare @LastName Varchar(50)
    declare @Trible Varchar(50)
    declare @Gender Varchar(5)
    declare @Date_Of_Birth Datetime
    
    
    
    INSERT INTO Patient(Patient_Number,FirstName,LastName,Tribe,Gender,Date_Of_Birth)
    VALUES (@Patient_Number,@FirstName,@LastName,@Trible,@Gender,@Date_Of_Birth)
    IF @@ERROR <> 0
    BEGIN
    ROLLBACK
    RETURN
    
    END
    COMMIT
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a C# application that calls a stored procedure that produces an xml
Suppose you have the following... An ASP.NET web application that calls a stored procedure
How do you unit test your code that utilizes stored procedure calls? In my
.Net application calls Stored Procedure and returns collection which is stored as 'result.' I
I am trying to debug my application that calls some stored procedure. I don't
I'm working on a CLR stored procedure that calls a controller action in an
Background A web application calls a stored procedure to perform an intensive database update.
I'm using Dapper for some read-only database calls via a stored procedure. I've got
If my Vb.net or c# web application calls a stored procedure that returns data
I have a python program that calls a stored procedure from db2 database. I

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.