<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Breathing Spring &#187; SQL SERVER</title>
	<atom:link href="http://breathing-spring.com/category/sql-server/feed/" rel="self" type="application/rss+xml" />
	<link>http://breathing-spring.com</link>
	<description></description>
	<lastBuildDate>Tue, 29 Jun 2010 07:48:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Stored Procedure and Fetching Result in PHP</title>
		<link>http://breathing-spring.com/stored-procedure-and-fetching-result-in-php/</link>
		<comments>http://breathing-spring.com/stored-procedure-and-fetching-result-in-php/#comments</comments>
		<pubDate>Sun, 08 Mar 2009 12:37:14 +0000</pubDate>
		<dc:creator>Lamis</dc:creator>
				<category><![CDATA[SQL SERVER]]></category>

		<guid isPermaLink="false">http://breathing-spring.com/?p=60</guid>
		<description><![CDATA[ok I assume you know SQL server here now to create a procedure you to to
Stored Procedure-&#62; New Stored Procedure
CREATE procedure dbo.NAME_OF_THE_PROCEDURE
@id int,
@name varchar(250)
As
select * dbo.TABLE_NAME
where
id=@id AND name like @name;
GO

the first two variables refer to the data we will send to the procedure, this will also work on insert.
to fetch the result in PHP first ]]></description>
			<content:encoded><![CDATA[<p>ok I assume you know SQL server here now to create a procedure you to to</p>
<p>Stored Procedure-&gt; New Stored Procedure</p>
<p><code>CREATE procedure dbo.NAME_OF_THE_PROCEDURE<br />
@id int,<br />
@name varchar(250)<br />
As<br />
select * dbo.TABLE_NAME<br />
where<br />
id=@id AND name like @name;<br />
GO<br />
</code><br />
the first two variables refer to the data we will send to the procedure, this will also work on insert.<br />
to fetch the result in PHP first we need to connect PHP to SQL SERVER<br />
<code><br />
$settings;<br />
	$db_host = "127.0.0.1"; //THE SQL SERVER IP so you can connect<br />
	$ser =  "127.0.0.1";  //THE SQL SERVER IP so you can connect<br />
	$db_name				= "DBNAME"; //DATABASE NAME TO CONNECT<br />
	$settings['db_user']    ="username_for_sql";<br />
	$settings['db_pass']    = "pass_for_sql";<br />
	$settings['dsn'] =         "DRIVER={SQL SERVER};" .<br />
		"Server=$ser;".<br />
		"CommLinks=tcpip(Host=$db_host);" .<br />
        "DatabaseName=$db_name;" .<br />
        "uid=".$settings['db_user']."; pwd=".$settings['db_pass']."";<br />
        $connection=odbc_connect($settings['dsn'], $settings['db_user'] , $settings['db_pass'] ,SQL_CUR_USE_ODBC);<br />
</code></p>
<p>Now finally fetching the Select result (I added how to select Database though its not necessary and only needed if you are switching to another database at the same connection<br />
<code><br />
odbc_exec($connection,"use other_db_name"); //only needed if you are switching database<br />
$query="exec NAME_OF_THE_PROCEDURE  23,'name'"; //23 is the ID, and 'name' is the name<br />
$result=odbc_exec($connection,$query); //result will return the one value fetched<br />
while ($row= odbc_fetch_array($result))<br />
{<br />
$i++;<br />
	 echo $row['anything1'].$row['someotherfeild'];<br />
}	 </p>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://breathing-spring.com/stored-procedure-and-fetching-result-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
