473,657 Members | 2,475 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to capture MSSQL SP output / multiple select statement results?

36 New Member
Hi All,

I'm facing a problem I'm unable to find a solution for. I hope fellow members would be able to help me out.


System Info:

PHP v5
MSSQL 2008
Linux box


Ok lets say I have a stored procedure called proc_getData which has 2 select
statements....

Expand|Select|Wrap|Line Numbers
  1. Create Proc proc_getdata
  2. AS
  3. Select COUNT(*) From Usr_Accounts;
  4. select top 1 * from Usr_Accounts;

then within my PHP script I called the procedure.. EXEC proc_getData;

How would it be possible to set each select statement from the procedure
into different results? so I could loop through each as and when needed on
my page?


Or,


Second way I tried out is that I have a SP with a single select statement but with an
OUTPUT parameter.

How do I capture the OUTPUT parameter while work with the result set of
select statement also.

Expand|Select|Wrap|Line Numbers
  1. Create Proc proc_getdata1 @cnt int OUTPUT
  2. AS
  3. SELECT @cnt = COUNT(*) FROM Usr_Accounts; PRINT @cnt
  4. Select top 1 * From Usr_Accounts;

SQL Statement being executed:
Expand|Select|Wrap|Line Numbers
  1. DECLARE @cnt INT SET @cnt = 0
  2. Exec proc_getdata1 @cnt OUTPUT
  3. SELECT @cnt


I want to capture my count variable @cnt to do paging while displaying the
Select statement result set on the web page.


Thanks and expecting a good response to my question
Ankit
Jan 29 '10 #1
2 4823
Atli
5,058 Recognized Expert Expert
@ankitmathur
You could try the mssql_next_resu lt function. It should allow you to use multiple result sets. (See the example in the manual)

@ankitmathur
You have a MSSQL server on a Linux box? Or is it a remote server?
Jan 30 '10 #2
ankitmathur
36 New Member
Hi Atli,

Your response sure has helped me inch closer. I'm still trying to use this function of PHP as I didn't had much info about it. Will get back if I get stuck again.

THANKS
Ankit
Feb 1 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
7029
by: Philip Mette | last post by:
I am in a crunch and need to covert this Oracle statement to MSSQL. Is there any Oracle/MSSQL experts out there that can help me? I do not understand the syntax enough to modify this. Thanks so much for any assistance. Here is the procedure. CREATE PROCEDURE UPD_ACTIVITY IS CURSOR ACT_cur1 IS SELECT DISTINCT A.ACCT_NUM, A.DUE_DATE
8
13996
by: Yusuf INCEKARA | last post by:
I have a stored procedure : CREATE PROCEDURE STP_GETSTORELIST @RETCUR CURSOR VARYING OUTPUT AS set @RETCUR = CURSOR FORWARD_ONLY STATIC FOR SELECT ID,STORE_NAME FROM T_INF_STORE ORDER BY STORE_NAME OPEN @RETCUR
2
2623
by: a | last post by:
how to send an xml dataset to a Stored Procedure in mssql I have an xml file that I read into a dataset. and I'm trying to use a stored procedure (see SPROC #1 below) that inserts this xml dataset into an sql table via OpenXML. Nothing gets inserted into the sql table except nulls, so I think that perhaps I'm not actually sending the (xml) dataset to the SPROC. The code below fails on this line: sqlCommand1.ExecuteNonQuery();
28
2237
by: kiqyou_vf | last post by:
I'm trying to pull data from 2 different tables and do a loop to retrieve more than one row. I'm having problems with aligning the information. Can someone lead me in the right direction? I've done some looking myself and found something called GROUP BY? Is that what I need to use? Thanks in advance.
8
2686
by: Alec MacLean | last post by:
Hi, I'm using the DAAB Ent Lib (Jan 2006) for .NET 2.0, with VS 2005 Pro. My project is a Web app project (using the WAP add in). Background: I'm creating a survey system for our company, for which invites will target selected personnel among our customers via email. Each email will provide a custom hyperlink for each respondent using a SQL generated GUID value in the querystring. The GUID will be checked for validity before the user...
7
4548
by: jb1 | last post by:
Hello All, I am trying to create a DTS package. I have two tables tbl_A and tbl_B with similar data/rows but no primary keys. tbl_A is master. I would like this package to query tbl_A and tbl_B and find 1)all rows in tbl_A that are different in tbl_B, 2)all rows in tbl_A that are not present in tbl_B and
14
2920
by: guswebb | last post by:
Hi. I'm a newbie to PHP and am having a few problems as follows... I have installed PHP successfully on server 1 which is running IIS 6 (W2k3) and hosting multiple sites, some of which connect to MSSQL 2k (SP4) on server 2 (using ASP). I can load a basic 'Hellow world' PHP page hosted on server1 but when I add the code to create a simple connection to MSSQL on server 2, my PHP doesn't seem to connect nor output any of the desired query...
17
12478
by: ukchat | last post by:
I.m creating a dynamic query to pull out workbooks from my database the table structure is below. Table: curricworkbooks Columns: ID, curric, assessment, topic, workbook, filename Example data 1 N1/E1.1 Numeracy E1 Count 1 workbooks/Num Entry 1/Unit 1/04 N1E1.1-3 Worksheets Num.pdf 10 MSS1/E1.6 Numeracy E1 Capacity 13 workbooks/Num Entry 1/Unit 13/04 MSS1E1.6 Worksheets Num.pdf
3
8618
by: Tim | last post by:
Hi Folks, I'm used to a UNLOAD command that allows me to dump to a named flat file the results of any SELECT statement. Hence one can build a single SQL file which contains multiple SQL statements each of which 'unloads' to its own unique file. unload to 'file1.txt' select * from ...... unload to 'file2.txt' select * from ...... and so on....
3
2106
by: tiptap | last post by:
Hey, I have a really confusing problem here. I'm using MSSQL & PHP. I have created a querry in MSSQL that basically shows a list of events and shows them in date order. I have written a bit of code into the mssql statement that says 'If the current date is the friday before the event date, and the event date is on a saturday or sunday, then dont show that event' when I run that code in mssql it returns the correct results - when its firday...
0
8323
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8739
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8513
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7351
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5638
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2740
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1732
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.