SQL Server is a stored procedure written in C # in .NET 2.0 with the SqlInt32 parameter. I am trying to make the parameter optional. Here is a minimal test case that just prints the integer passed to it:
[Microsoft.SqlServer.Server.SqlProcedure]
public static void TestProc(
SqlInt32 TestInt
)
{
SqlPipe pipe;
pipe = SqlContext.Pipe;
if (TestInt.IsNull)
{
pipe.Send("NULL value passed");
}
else
{
pipe.Send(TestInt.ToString());
}
}
These commands execute as expected and print the values "1" and "NULL", respectively:
exec dbo.TestProc @TestInt = 1
exec dbo.TestProc @TestInt = null
However, my goal is to set the default value to NULL for @TestInt, which will allow me to execute only this command:
exec dbo.TestProc
.NET. , Googling,.NET 4.0 , , ,.NET 2.0 . () , , " ":
SqlInt32 TestInt = SqlInt32.Null
, :
public static void TestProc()
{
SqlInt32 intNull;
intNull = SqlInt32.Null;
TestProc(intNull);
}
, : VS " , ". .
, , : TSQL, . , , TSQL .NET. , , . , , . TSQL procs , , , , .NET.