When i execute a stored procedure with output parameters do i need to give them value null?

So i am making an erp program for practice from adventureworks2019 database in management studio in sql and one stored procedure with output parameters didnt run properly unless i specified their value as null, while others similar procedures did not have such an issue. Why? and are the other procedures faulty? What is the textbook way syntactically executing procedures with output parameters?, also any tips pls?

drop procedure if exists sohead;

create procedure sohead
@BusinessEntityid int,
@customerid int,
@persontype nchar(2) output,
@storeid int output,
@orderdate datetime output,
@duedate datetime output,
@accountnumber nvarchar(15) output,
@salespersonid int output,
@territoryid int output,
@billToAddressid int output,
@shipToAddressid int output,
@shipMethodid int,
@creditcardid int output,
@currencyrateid int =null,
@subtotal money,
@taxamt money,
@freight money,
–totaldue self generated and computed
@comment nvarchar(128)

AS
BEGIN
set nocount on;
begin try

        begin transaction
        --@storeid
        
            select @storeid = storeid from sales.customer where CustomerID = @customerid;

        --orderdate 
        SET @orderdate = GETDATE();

        --duedate
        SET @duedate = DATEADD(day, 15, @orderdate);


        --salespersonid
        
        if @storeid IS NULL
            SET @salespersonid = NULL;
        else
            SELECT @salespersonid = SalesPersonID 
            FROM Sales.Store 
            WHERE BusinessEntityID = @storeid;


        --territoryid
        select @territoryid = territoryid from sales.Customer
        where customerid = @customerid;

        --biiltoaddress  AND  shipaddressid
        --;WITH persontypecte AS (
        --      SELECT persontype 
        --      FROM person.Person
        --      WHERE BusinessEntityID = @businessentityid
        --  )
        --select @persontype = persontype from persontypecte
        select @persontype = persontype FROM person.Person
                WHERE BusinessEntityID = @businessentityid;

        if @persontype = 'SC' 
        BEGIN
                    ;with billshipadd as(
                        SELECT AddressID FROM  
                        person.BusinessEntityAddress

                        where BusinessEntityid = @storeid

                    )
                    select   @BILLTOADDRESSID = addressid,@SHIPTOADDRESSID = addressid  from billshipadd; --address GIA 'SC'
        
        END
        ELSE IF @PERSONTYPE = 'IN' 
        BEGIN
                    ;with billshipadd as(
                        SELECT AddressID FROM  
                        person.BusinessEntityAddress

                        where BusinessEntityid = @businessentityid

                    )
                    select   @BILLTOADDRESSID = addressid,@SHIPTOADDRESSID = addressid  from billshipadd; --address gia 'IN'
        END;             

        --creditcardid

        select @creditcardid =  CreditCardID from Sales.PersonCreditCard where businessentityid = @BusinessEntityid;

        --accountnumber 

        select @accountnumber = accountnumber from sales.customer where customerid = @customerid;

        --currencyrateid

        --null

        


        


        insert into sales.salesorderheader(revisionNumber, orderdate, duedate, shipdate, status,
        onlineorderflag, purchaseordernumber, accountnumber, customerid, salespersonid, territoryid,        
billtoaddressid, shiptoaddressid, shipmethodid, creditcardid, creditcardapprovalcode,       
currencyrateid, subtotal, taxamt, freight, comment, rowguid, modifieddate)
        VALUES(
        0,
        @orderdate,
        @duedate,
        null,
        1,
        0,
        null,
        @accountnumber,
        @customerid,
        @salespersonid,
        @territoryid,
        @billToAddressid,
        @shipToAddressid,
        @shipMethodid,
        @creditcardid,
        null, --credit card approval code
        @currencyrateid,
        @subtotal,
        @taxamt,
        @freight,
        --@totaldue, --mono toy
        @comment,
        newid(),
        getdate()
);

        commit transaction
    end try
    begin catch 
        SELECT
            ERROR_NUMBER() AS ErrorNumber,
            ERROR_SEVERITY() AS ErrorSeverity,
            ERROR_STATE() AS ErrorState,
            ERROR_MESSAGE() AS ErrorMessage;

    IF @@TRANCOUNT > 0
        rollback transaction;
        throw;
    end catch

end;

exec sohead @businessentityid=1983 , @customerid=30113 ,@shipmethodid= 1, @subtotal =5,
@taxamt =5, @freight = 5, @comment = null,@persontype = null, @storeid = null,@orderdate = null, @duedate = null, @accountnumber= null, @salespersonid= null,
@territoryid = null, @billToAddressid = null, @shipToAddressid=null, @creditcardid = null;

Apparrently this is the right way to execute it
but i thought this was enough : exec sohead @businessentityid=1983 , @customerid=30113 ,@shipmethodid= 1, @subtotal =5,
@taxamt =5, @freight = 5;

New contributor

user23592235 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật