I'm calling a stored procedure with named parameter.
exec MySP @name = 'binesh', @amount = @amt, @date = @date
It's working fine for me.
But when I'm trying
exec MySP2 @name = 'binesh', @amount = -@amt, @date = @date
or
exec MySP3 @name = 'binesh', @amount = @amt, @date = convert(varchar(25), @date, 131)
I get a syntax error.
Is this mandatory that I need to create separate variables for each (common sense tells it won't be the way). So what is the syntax for this?
Thanks all
Binesh
As a program, a stored procedure can take parameters. There are three types of parameters: IN, OUT and INOUT.
Expand the database that you want, expand Programmability, and then expand Stored Procedures. Right-click the user-defined stored procedure that you want and select Execute Stored Procedure. In the Execute Procedure dialog box, specify a value for each parameter and whether it should pass a null value.
Parameters are used to exchange data between stored procedures and functions and the application or tool that called the stored procedure or function: Input parameters allow the caller to pass a data value to the stored procedure or function.
UDF can be used in the SQL statements anywhere in the WHERE/HAVING/SELECT section where as Stored procedures cannot be. UDFs that return tables can be treated as another rowset. This can be used in JOINs with other tables.
You can not construct input "in-line" for stored procedures. You must resolve the inputs prior to using them.
For example, you need to do something like this (as well as resolve the other parameters) ...
declare
@date varchar(25) = convert(varchar(25), @date, 131);
exec MySP3 @name = 'binesh', @amount = @amt, @date = @date;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With