0

The situation: I am using Allen-Bradley (Rockwell) software package known as FactoryTalk Transaction Manager, which allows PLC's to use the power of SQL Server to do things.

Using SQL Server 2012, I need to specify the direction of parameters within the stored procedure, which I incorrectly assumed was as simple as an

@QuarantineReason nvarchar(256) OUTPUT

However when viewed in the Object Explorer of SSMS the properties for the stored procedure parameter shows

@QuarantineReason (nvarchar(256), Input/Output, No default)

In order to simplify my life greatly, I would like the parameter to be an output only, as this saves me binding the input side of things in the Allen-Bradley software.

I found several MS documentation resources online but they all seem to specify C# as the codebase, which is bewildering to me.

SqlParameter.Direction Property

Input, Output and Input/Output SqlParameter Behavior Explained

Using a Stored Procedure with Output Parameters

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • 2
    AFAIK there is no Output Only option – user1443098 Nov 19 '18 at 15:54
  • 1
    Possible duplicate of [How To Declare Input-Output Parameters In SQL Server Stored Procedure/Function?](https://stackoverflow.com/questions/49129536/how-to-declare-input-output-parameters-in-sql-server-stored-procedure-function) – JohnLBevan Nov 19 '18 at 15:55
  • There is no such thing as an output-only parameter in T-SQL; it is always possible to pass an input value, and this value will be available to the code. Client code that treats such a parameter as "output only" simply doesn't specify an value when calling the procedure. Unless, of course, it doesn't know about this T-SQL quirk, as appears to be the case here. Consider giving the parameter an explicit but unused dummy default (`@QuarantineReason NVARCHAR(256) OUTPUT = NULL`); the software might detect this and allow you to omit the input binding. – Jeroen Mostert Nov 19 '18 at 16:02
  • @JeroenMostert Please answer with your comment, and I will accept it as the most relevant answer. It is very clear and addresses the client software and everything. – Eric Carson Nov 19 '18 at 16:18

1 Answers1

0

As far as I know, you can't do that in MSSQL, and you would have to specify the direction when calling the SP (as well as in the parameter declaration of the SP itself).

The documentation you found with C# examples is for calling an MSSQL SP from .NET C# code.

Hope this helps.

sfanty
  • 31
  • 4