Interview Questions Answers.ORG
Interviewer And Interviewee Guide
Interviews
Quizzes
Home
Quizzes
Interviews Databases Programming Interviews:BtrieveClipperData ModelingData StructuresDatabase AdministrationDatabase Administrator (DBA)Database AnalystDatabase DeveloperDB DevelopmentEDI/Data Integration ExpertFirebirdHierarchicalIBM DB2InformixJava DatabaseMariaDBMicrosoft Access DeveloperMongoDBMS SQL ServerMySQL ProgrammingNetworkNoSQLObject RelationalPostgrePostgreSQLProgressRDBMSRelationalSQLSQL AdministratorSQL and PL/SQLSQL Notification ServicesSQL server 2008SSRSStored ProcedureSybaseTeradata
Copyright © 2018. All Rights Reserved
MS SQL Server Interview Question:
How To Loop through Result Set Objects using odbc_fetch_row()?
Submitted by: AdministratorIf the returning output of a query statement is captured in a result set object, you can use odbc_fetch_row() to loop through each row in the output.
The tutorial PHP script below shows you how to list tables in the database:
<?php
$con = odbc_connect('ggl_SQL_SERVER','sa','GlobalGuideLine');
$sql = "SELECT * FROM sys.objects"
. " WHERE type_desc='USER_TABLE'";
$res = odbc_exec($con, $sql);
print("User Tables: ");
while (odbc_fetch_row($res)) {
print(" ".odbc_result($res,'name')." ");
}
odbc_free_result($res);
odbc_close($con);
?>
If you run this script, you will get something like:
User Tables:
ggl_rates
ggl_team
ggl_random
ggl_links_indexed
ggl_links
ggl_links_copy
tipBackup2
Submitted by: Administrator
The tutorial PHP script below shows you how to list tables in the database:
<?php
$con = odbc_connect('ggl_SQL_SERVER','sa','GlobalGuideLine');
$sql = "SELECT * FROM sys.objects"
. " WHERE type_desc='USER_TABLE'";
$res = odbc_exec($con, $sql);
print("User Tables: ");
while (odbc_fetch_row($res)) {
print(" ".odbc_result($res,'name')." ");
}
odbc_free_result($res);
odbc_close($con);
?>
If you run this script, you will get something like:
User Tables:
ggl_rates
ggl_team
ggl_random
ggl_links_indexed
ggl_links
ggl_links_copy
tipBackup2
Submitted by: Administrator
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.
https://InterviewQuestionsAnswers.ORG.