Php calls the mssql stored procedure instance application. Use the mssql_init statement to initialize the stored procedure, then call the mssql_bind statement to specify the stored procedure parameters, and finally call mssql_execute to execute the stored procedure. The php Tutorial calls the mssql stored procedure and uses the mssql_init statement to initialize the stored procedure. then, the mssql_bind statement is called to specify the stored procedure parameters, and mssql_execute is called to execute the stored procedure.
Php Tutorial call mssql stored procedure instance application
Use the mssql_init statement to initialize the stored procedure, then call the mssql_bind statement to specify the stored procedure parameters, and finally call mssql_execute to execute the stored procedure.
*/
// Connect to the mssql database tutorial server
$ Link = mssql_connect ("127.0.0.1", "sa", "sa") or die ("Can't connect SQL server ");
Mssql_select_db ("frrc", $ link) or die ("Select database failure ");
// Initialize and load the stored procedure Bigdatabase
$ Stmt = mssql_init ("Bigdatabase", $ link) or die ("initialize stored procedure failure ");
Mssql_bind ($ stmt, "@ pagesize", $ pagesize, SQLINT4 );
Mssql_bind ($ stmt, "@ start", $ start, SQLINT4 );
@ $ Ms_result = mssql_execute ($ stmt, false );
Mssql_query ("dump transaction tempdb WITH NO_LOG ");
Do {
While ($ ms_rs = mssql_fetch_object ($ ms_result ))
{
// Process data
}
}
// The msssql stored procedure Bigdatabase is as follows:
/*
Create procedure Bigdatabase
@ Pagesize int,
@ Start int
AS
Declare @ bsql nvarchar (4000)
Set @ bsql = 'SELECT top '+ str (@ pagesize) + 'username, jobid, password, useremail, zcdata, ip, name, xingbie, minzu, xueli, hunyin, age, example, zyclass, example, huji, huji1, shengao, byear, birthyear, birthmonth, birthday, dianhua, qq, Hangzhou, selectedjob1, selectedjob2, selectedjob3, s_PWL1, s_PWL2, s_PWL3, protocol, Negotiable, protocol, availOpts, availNotice, llcs, CONVERT (varchar (100), dlsj, 25) as dlsj, xgsj, dlcs, primary, primary age_one, l_OneAbility, primary age_two, l_twoAbility, mandarinLevel, skillkey, jingyan, photopb, photo, phototre, mbsys, codetype, code, shouji, posts, address, jobtype, convert (varchar (8000), pingjia) as large, convert (varchar (8000), jinengzhuanchang) as jinengzhuanchang, convert (varchar (8000), fazhanfangxiang) as fazhanfangxiang, convert (varchar (8000), other) as other from person where id not in (select top '+ str (@ start) + 'Id from person order by id asc) order by id asc'
Execute sp_executesql @ bsql
GO
Note: text must be converted to varchar. otherwise, problems may occur.
The original article on this site is Reprinted and indicated that the source is www. bKjia. c0m, the first stop of the Chinese WEB site
Bytes. Php Tutorial call mssql stored procedure...