IT Community - Software Programming, Web Development and Technical Support

Executing SQL Server Stored Procedures With PHP - Executing stored procedures

This is a discussion on Executing SQL Server Stored Procedures With PHP - Executing stored procedures within the PHP Programming forums, part of the Web Development category; hi, Here we can see to execute SP from PHP page Executing a stored procedure with PHP and the mssql_xxx ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > PHP Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 07-19-2007, 12:12 AM
Jeyaseelansarc Jeyaseelansarc is offline
D-Web Genius
 
Join Date: Mar 2007
Location: Chennai
Posts: 1,162
Jeyaseelansarc is on a distinguished road
Send a message via AIM to Jeyaseelansarc
Default Executing SQL Server Stored Procedures With PHP - Executing stored procedures

hi,
Here we can see to execute SP from PHP page

Executing a stored procedure with PHP and the mssql_xxx set of functions is easy. To execute a stored procdure that accepts no parameters and doesn't return a value, we only need to make use of the mssql_init and mssql_execute functions.

To create SP

GO

CREATE PROC sp_test

AS

-- Add a record to the shippers table

INSERT INTO test(CompanyName, Phone)

VALUES('Buddies Infotech', '044-43009605');

To execute from PHP page

<?php

$myServer = "localhost";

$myUser = "sa";

$myPass = "";

$myDB = "test";

$s = @mssql_connect($myServer, $myUser, $myPass)

or die("Couldn't connect to SQL Server on $myServer");

$d = @mssql_select_db($myDB, $s)

or die("Couldn't open database $myDB");

$query = mssql_init("sp_test", $s);//call SP

$result = mssql_execute($query);//Execute the SP as a query

?>
__________________
With,
J. Jeyaseelan

Everything Possible
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-19-2007, 12:23 AM
Jeyaseelansarc Jeyaseelansarc is offline
D-Web Genius
 
Join Date: Mar 2007
Location: Chennai
Posts: 1,162
Jeyaseelansarc is on a distinguished road
Send a message via AIM to Jeyaseelansarc
Default Re: Executing SQL Server Stored Procedures With PHP - Executing stored procedures

We can also run our stored procedure using query analyzer with the following code:
use test
EXEC sp_test

If we have any param it should give along with

like
EXEC sp_test 2

Here 2 is the param sent to the SP
__________________
With,
J. Jeyaseelan

Everything Possible
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Performance Tuning Tips About Sql Server Stored Procedures vadivelanshanmugam Database Support 0 02-04-2008 06:16 AM
Performance Tuning Tips About Sql Server Stored Procedures vadivelanshanmugam Database Support 0 02-04-2008 06:14 AM
Some Performance tuning tips about SQL Server Stored Procedures vadivelanshanmugam Database Support 0 02-04-2008 06:12 AM
SQL Server Undocumented Stored Procedures a.deeban Database Support 2 12-23-2007 11:20 PM
SQL Server Undocumented Stored Procedures a.deeban Database Support 3 09-04-2007 03:31 AM


All times are GMT -7. The time now is 01:28 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0