0

I have a very simple SQL Stored Procedure to get a field from a table. I want to run the stored procedure from a batch file and get the field to a batch variable

create procedure dbo.sp_SelectCustomerCode @ipOrderNo NVARCHAR(50), @outputData Nvarchar(30) output
as
begin
    select @outputData = CustomerCode from OrderHeader
    where OrderNo = @ipOrderNo
end

I want the Batch File is something like that

sqlcmd -S Server123 -b -d DataBase -U XXXX -P YYYY -Q "EXEC dbo.sp_SelectCustomerCode '10001', @ipOrderNo out " > Test.log


@echo @ipOrderNo 

Is it possible to do that? Thank you very much

  • Possible duplicate: https://stackoverflow.com/questions/27624252/how-to-set-a-sqlcmd-output-to-a-batch-variable – Wolfgang Kais Aug 30 '18 at 08:03
  • Possible duplicate of [How to set a sqlcmd output to a batch variable?](https://stackoverflow.com/questions/27624252/how-to-set-a-sqlcmd-output-to-a-batch-variable) – Wolfgang Kais Aug 30 '18 at 08:04

0 Answers0