Advertisement

02.22.2008 at 05:20PM PST, ID: 23186401
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

calling a stored procedure in a while loop in ms sql

Tags: microsoft, sql
I am trying to call a stored procedure in a while loop but for some
reason it only returns 1 row whereas I am expectint 12 rows
Here is the stored procedure and the call

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

ALTER procedure [dbo].[SP_FETCH_ROWS](@num int)
AS

SELECT Table_Name from TestData6061.INFORMATION_SCHEMA.Tables a where
@num =(select count(*) from TestData6061.INFORMATION_SCHEMA.Tables b
where a.Table_Name >= b.Table_Name)
go

While Loop which calls the stored procedure and passing the loop
counter as the argument
DECLARE @Count int DECLARE @MaxCount int
SET              @Count = 0
SET              @MaxCount = 29 WHILE @Count < @MaxCount BEGIN
SET              @Count = @Count + 1 IF @Count = 1 OR
                      @Count = 4 OR
                      @Count = 7 OR
                      @Count = 8 OR
                      @Count = 14 OR
                      @Count = 17 OR
                      @Count = 18 OR
                      @Count = 22 OR
                      @Count = 25 OR
                      @Count = 27 OR
                      @Count = 28 OR
                      @Count = 29 EXEC releases.dbo.SP_FETCH_ROWS
@Count END

what am I missing here? I tried to figure out n looked for all kinds
of online documentation but still couldn't find the solution. please
help
Start your free trial to view this solution
Question Stats
Zone: Microsoft
Question Asked By: vikrantp
Solution Provided By: chapmandew
Participating Experts: 2
Solution Grade: A
Views: 103
Translate:
Loading Advertisement...
02.22.2008 at 06:56PM PST, ID: 20963392

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.23.2008 at 09:27AM PST, ID: 20965709

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.23.2008 at 11:36AM PST, ID: 20966279

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.23.2008 at 11:45AM PST, ID: 20966316

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.23.2008 at 12:08PM PST, ID: 20966426

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.23.2008 at 12:40PM PST, ID: 20966581

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.23.2008 at 03:17PM PST, ID: 20967259

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.23.2008 at 03:22PM PST, ID: 20967276

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.23.2008 at 03:25PM PST, ID: 20967283

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.23.2008 at 03:49PM PST, ID: 20967379

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.23.2008 at 04:04PM PST, ID: 20967439

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.23.2008 at 04:08PM PST, ID: 20967458

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.23.2008 at 04:19PM PST, ID: 20967508

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.23.2008 at 07:48PM PST, ID: 20968383

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.25.2008 at 12:38PM PST, ID: 20978972

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.25.2008 at 12:39PM PST, ID: 20978987

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.25.2008 at 12:40PM PST, ID: 20978996

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.25.2008 at 01:00PM PST, ID: 20979187

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.25.2008 at 01:02PM PST, ID: 20979208

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.25.2008 at 06:08PM PST, ID: 20981123

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.25.2008 at 06:12PM PST, ID: 20981144

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
02.22.2008 at 06:56PM PST, ID: 20963392

Rank: Genius

Are you sure there is no error occurring in your sp_fetch_rows stored procedure?  I modified your code just a bit and it printed out 12 times for me.

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
DECLARE @Count int 
 
DECLARE @MaxCount int
SET              @Count = 0
SET              @MaxCount = 29 
 
WHILE @Count < @MaxCount 
BEGIN
SET              @Count = @Count + 1 
 
						IF @Count = 1 OR
                      @Count = 4 OR
                      @Count = 7 OR
                      @Count = 8 OR
                      @Count = 14 OR
                      @Count = 17 OR
                      @Count = 18 OR
                      @Count = 22 OR
                      @Count = 25 OR
                      @Count = 27 OR
                      @Count = 28 OR
                      @Count = 29 
					
					PRINT CAST(@COUNT AS VARCHAR(50))
 
END
Open in New Window
 
02.23.2008 at 09:27AM PST, ID: 20965709
I think you have dynamically created tables, which can be ordered by name (e.g. perhaps the name is based on a date string), and you're calling the stored procedure to find out how many successors each table has (or in other words how old it is).  Is that so?

Whatever the reason, the reason you're seeing only one row may lie in the fact that if you call a stored procedure 12 times from the frontend the front-end may discard the first 11th and show you only the last result.  If you want to keep all, declare a table variable just before you start your While loop, and do Insert...Exec inside the loop, so that the returns will add up to the table variable.  On exiting the loop select * from the table variable and the front-end should show the proper thing.
 
02.23.2008 at 11:36AM PST, ID: 20966279
So it seems like I don't really have to look into the Information
shcema for TestData6061 as I mentioned earlier in the code. Thosee table names can be accessed as

SELECT DISTINCT ObjectClass
FROM         SchemaFields
ORDER BY ObjectClass
and that will give me something like this ->

accounting
fundstructures
investment
sync
...
...
...
Now coming back to the looping, I basically want to have a sql query
which will loop through the above list (accounting, investment, etc
etc) giving me the single value as it goes through the loop. Thanks in
advance
 
02.23.2008 at 11:45AM PST, ID: 20966316

Rank: Genius

Ummm...what kind of single value are you looking for?
 
02.23.2008 at 12:08PM PST, ID: 20966426
well basically I want to access the output of that sql query, one by one, thats what I meant by single value, sorry if I confused you or anything.
As I mentioned I want to be able to access 'accounting', 'fundsturctures' etc from the output of the query
 
02.23.2008 at 12:40PM PST, ID: 20966581

Rank: Genius

Ok, forgive me because I am not sure I understand fully what you are trying to accomplish.  Are you just trying to do work on each record provided?  Do you need to call a proc w/ that value?  Maybe (I am not sure) this will lead you in the right direction
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
DECLARE @ObjectClass VACHAR(200)
 
DECLARE  CursorTemplate CURSOR 
FAST_FORWARD FOR 	
SELECT DISTINCT ObjectClass
FROM         SchemaFields
ORDER BY ObjectClass
 
OPEN CursorTemplate
 
FETCH NEXT FROM CursorTemplate 
INTO	@ObjectClass
 
WHILE (@@FETCH_STATUS = 0)
BEGIN
 
	PRINT @ObjectClass
	--some other code to do something with @ObjectClass
	FETCH NEXT FROM CursorTemplate 
	INTO	@ObjectClass
 
END
 
CLOSE CursorTemplate
DEALLOCATE CursorTemplate
Open in New Window
 
02.23.2008 at 03:17PM PST, ID: 20967259
So the above cursor actually works but the problem is it works only when I run the query through 'New Query' on the GUI n it shows me a list of all the object classes like accntg, calendar etc.
But If I just open Schema or SchemaFields table and then click on 'Show SQL Pane' n execute it over there, it just shows me 'Query has executed successfully' but doesn't show anything in the output
I am attaching a file showing the print screen when run through the 'sql pane' for schema table and the other one used with 'New Query' on the MS SQL GUI which works fine
 
This is when I run your query through a SQL pane for releases.dbo.schema table
This is when I run your query through a SQL pane for releases.dbo.schema table
 
 
This is when I run your query through 'New Query' on the GUI
This is when I run your query through 'New Query' on the GUI
 
 
02.23.2008 at 03:22PM PST, ID: 20967276
The Idea is to run a query (using functions/stored procedure etc) which will be of the form
EXECUTE <sp_name> 'TestData6061', 'accounting', 133
accounting ist going to be changing.
So I want to have a loop in which I just execute the above stored procedure and assign value to the middle parameter dynamically depending on the value got from the cursor (defined by chapmandew). Thanks in advance
 
02.23.2008 at 03:25PM PST, ID: 20967283

Rank: Genius

That is what I was thinking...we can just tweak the cursor code a bit to call the proc...just replace the proc name w/ yours.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
DECLARE @ObjectClass VACHAR(200)
 
DECLARE  CursorTemplate CURSOR 
FAST_FORWARD FOR 	
SELECT DISTINCT ObjectClass
FROM         SchemaFields
ORDER BY ObjectClass
 
OPEN CursorTemplate
 
FETCH NEXT FROM CursorTemplate 
INTO	@ObjectClass
 
WHILE (@@FETCH_STATUS = 0)
BEGIN
 
	PRINT @ObjectClass
	EXECUTE usp_ProcedureName 'TestData6061', @ObjectClass, 133
	FETCH NEXT FROM CursorTemplate 
	INTO	@ObjectClass
 
END
 
CLOSE CursorTemplate
DEALLOCATE CursorTemplate
Open in New Window
Accepted Solution
 
02.23.2008 at 03:49PM PST, ID: 20967379
So I tried to call my stored procedure (not written by me, my manager wrote it and supposed to be right) as you mentioned as below
EXECUTE spLoaderCoverageObjectTypeActionType 'TestData6061', @ObjectClass, 136
but I just see the results for 'accounting' whereas it should be showing 'accounting', 'fundstructures', 'transaction' etc (all object classes)

Here is the code for the stored procedure for you

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

ALTER PROCEDURE [dbo].[spLoaderCoverageObjectTypeActionType]
      @sDatabaseName sysname,
    @sTableName sysname,
    @iSchemaID int
AS
BEGIN
      SET NOCOUNT ON;
   EXEC ('SELECT     SchemaQuery.ObjectClass, SchemaQuery.ObjectType, SchemaQuery.ActionType, DataQuery.Count
           FROM  
             (SELECT DISTINCT ObjectClass, ObjectType, ''New'' AS ActionType
              FROM          SchemaFields
              WHERE      SchemaID = ' + @iSchemaID + ' AND ObjectClass LIKE ''%'+ @sTableName +'%'') AS SchemaQuery LEFT OUTER JOIN
                          (SELECT     TypesQuery.ObjectClass, TypesQuery.ObjectType, COUNT(*) AS Count
                            FROM          (SELECT DISTINCT ObjectClass, ObjectType
                                           FROM          SchemaFields AS SchemaFields_1
                                           WHERE      (SchemaID = ' + @iSchemaID + ')) AS TypesQuery INNER JOIN
                                                   ' + @sDatabaseName + '.dbo.' + @sTableName + ' ON TypesQuery.ObjectType = ' + @sDatabaseName + '.dbo.' + @sTableName + '.[01-RecordClass] AND
                                                   ' + @sDatabaseName + '.dbo.' + @sTableName + '.AutomationType = ''Loader'' AND
                                                   ' + @sDatabaseName + '.dbo.' + @sTableName + '.[Negative Testcase] = 0 AND
                                                   ' + @sDatabaseName + '.dbo.' + @sTableName + '.[02-RecordAction] = ''New''
                            GROUP BY TypesQuery.ObjectClass, TypesQuery.ObjectType) AS DataQuery ON SchemaQuery.ObjectClass = DataQuery.ObjectClass AND SchemaQuery.ObjectType = DataQuery.ObjectType
           UNION
           SELECT     SchemaQuery.ObjectClass, SchemaQuery.ObjectType, SchemaQuery.ActionType, DataQuery.Count
           FROM  
             (SELECT DISTINCT ObjectClass, ObjectType, ''Update'' AS ActionType
              FROM          SchemaFields
              WHERE      SchemaID = ' + @iSchemaID + ' AND ObjectClass LIKE ''%'+ @sTableName +'%'') AS SchemaQuery LEFT OUTER JOIN
                          (SELECT     TypesQuery.ObjectClass, TypesQuery.ObjectType, COUNT(*) AS Count
                            FROM          (SELECT DISTINCT ObjectClass, ObjectType
                                           FROM          SchemaFields AS SchemaFields_1
                                           WHERE      (SchemaID = ' + @iSchemaID + ')) AS TypesQuery INNER JOIN
                                                   ' + @sDatabaseName + '.dbo.' + @sTableName + ' ON TypesQuery.ObjectType = ' + @sDatabaseName + '.dbo.' + @sTableName + '.[01-RecordClass] AND
                                                   ' + @sDatabaseName + '.dbo.' + @sTableName + '.AutomationType = ''Loader'' AND
                                                   ' + @sDatabaseName + '.dbo.' + @sTableName + '.[Negative Testcase] = 0 AND
                                                   ' + @sDatabaseName + '.dbo.' + @sTableName + '.[02-RecordAction] = ''Update''
                            GROUP BY TypesQuery.ObjectClass, TypesQuery.ObjectType) AS DataQuery ON SchemaQuery.ObjectClass = DataQuery.ObjectClass AND SchemaQuery.ObjectType = DataQuery.ObjectType  
           UNION
           SELECT     SchemaQuery.ObjectClass, SchemaQuery.ObjectType, SchemaQuery.ActionType, DataQuery.Count
           FROM  
             (SELECT DISTINCT ObjectClass, ObjectType, ''Delete'' AS ActionType
              FROM          SchemaFields
              WHERE      SchemaID = ' + @iSchemaID + ' AND ObjectClass LIKE ''%'+ @sTableName +'%'') AS SchemaQuery LEFT OUTER JOIN
                          (SELECT     TypesQuery.ObjectClass, TypesQuery.ObjectType, COUNT(*) AS Count
                            FROM          (SELECT DISTINCT ObjectClass, ObjectType
                                           FROM          SchemaFields AS SchemaFields_1
                                           WHERE      (SchemaID = ' + @iSchemaID + ')) AS TypesQuery INNER JOIN
                                                   ' + @sDatabaseName + '.dbo.' + @sTableName + ' ON TypesQuery.ObjectType = ' + @sDatabaseName + '.dbo.' + @sTableName + '.[01-RecordClass] AND
                                                   ' + @sDatabaseName + '.dbo.' + @sTableName + '.AutomationType = ''Loader'' AND
                                                   ' + @sDatabaseName + '.dbo.' + @sTableName + '.[Negative Testcase] = 0 AND
                                                   ' + @sDatabaseName + '.dbo.' + @sTableName + '.[02-RecordAction] = ''Delete''
                            GROUP BY TypesQuery.ObjectClass, TypesQuery.ObjectType) AS DataQuery ON SchemaQuery.ObjectClass = DataQuery.ObjectClass AND SchemaQuery.ObjectType = DataQuery.ObjectType  

            ORDER BY  SchemaQuery.ObjectClass,  SchemaQuery.ActionType, SchemaQuery.ObjectType
')
END
 
02.23.2008 at 04:04PM PST, ID: 20967439

Rank: Genius

did you call it from within the cursor I detailed?
 
02.23.2008 at 04:08PM PST, ID: 20967458
yup, but it returned only the accounting. if its called in the loop, It should be be returning all the object classes
 
02.23.2008 at 04:19PM PST, ID: 20967508
what exactly is the difference between running sql query from a 'sql pane' for a table and clicking on 'New Query' on the MS SQL GUI n executing the same query. I get different results. Pleaset let me know if you know anything about it. Thanks a million
 
02.23.2008 at 07:48PM PST, ID: 20968383

Rank: Genius

Im not really sure...I always run SQL through 'New Query' in Management Studio....doing it that way is the way to go.  
 
02.25.2008 at 12:38PM PST, ID: 20978972
it works but the problem is that we have a output with indvidual results as shows in the attachment, Basically I want to have an output which will consolidate all the results of the cursor into a single table output form.
 
02.25.2008 at 12:39PM PST, ID: 20978987
Here the output when the cursor is ran but like I said basically I want to have the a consolidated output into a single table. Is there anyway to do that? Thanks in advance
 
cursor outout
cursor outout
 
 
02.25.2008 at 12:40PM PST, ID: 20978996

Rank: Genius

Alright.  I think this is about as far as I am going to go with this question.  I hope you feel that I have helped you.  If you need further help, I would submit another question.
 
02.25.2008 at 01:00PM PST, ID: 20979187
Okay, NP. Thanks chapmandew. I really appreciate your help with this one. Thanks a lot again. I have filed another one which says 'joining/transforming' output of a cursor into a single table.
 
02.25.2008 at 01:02PM PST, ID: 20979208

Rank: Genius

I kinda have a problem w/ getting no points for this question.  I feel I've helped you quite a bit on it.
 
02.25.2008 at 06:08PM PST, ID: 20981123
A request has been made in Community Support to close this question:
http://www.experts-exchange.com/Q_23191586.html

If there are no objections, a moderator will finalize this question in approximately 4 days as follows:
Accept expert comment {http:#a20968383}

Please leave any recommendations here.

ForestDenizen
Community Support Moderator
 
02.25.2008 at 06:12PM PST, ID: 20981144

Rank: Genius

I believe I should receive some points for this question...for the time I spent helping.  The author even commented on how they appreciated my help w/ the problem.
 
 
20080236-EE-VQP-29 / EE_QW_2_20070628