Home > php教程 > php手册 > body text

PHP 调用MSSQL存储过程

WBOY
Release: 2016-06-21 09:07:23
Original
804 people have browsed it

存储过程

存储过程如下:

CREATE PROCEDURE test
  @TableName char(20),
  @ii char(20) output,
  @bb char(20) output
AS
set nocount on
/*
if exists (select 1 from demo_table where t_name=@TableName)
  set @ii = 'yes'
else
  begin
    --RAISERROR('not have such a table',16,1)
    set @ii = 'no'
  end
*/
select @ii = t_id from demo_table where t_name = @TableName
if @ii is null
begin
  set @ii = 'no'
  set @bb = 'hello'
end
else
  set @bb = 'HAHAHAHAHQAH'
select @ii as ii,@bb as bb

GO


include "conn.php";//连接数据库
/*
$query = " exec test 'demo_kh'";
$r = $db->query($query);
$result = $db->fetch_array($r);
echo $result['t_name'];
*/
  $query = "declare @ii varchar(20),@bb varchar(20)\n";
  $query .= "execute test 'demo_kh',@ii output,@bb output\n";
  $r = $db->fetch_array($db->query($query));
  echo $r['ii'].$r['bb'];
?>




Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template