php调用MSSQL存储过程的方法时间:2022-05-14 14:05:43创建一个MSSQL存储过程: CREATE PROCEDURE dbo.P__Test_GetData(@UserId int,@UserName nvarchar(100) output)Asset nocount onselect @UserName = UserName from _Test where UserId = @UserIdset nocount offGO php中调用方法: <?phprequire 'dbconn.php';$userId = 1; // 定义输入参数 $userName; // 定义返回值$stmt = mssql_init("P__Test_GetData", $conn) or die("initialize stored procedure failure");mssql_bind($stmt, "@userid", $userId, SQLINT4);mssql_bind($stmt, "@username", $userName, SQLVARCHAR, true);$rs = mssql_execute($stmt, false);echo "This user name is: ".$userName;?> 返回结果: This user name is: BanLao.