Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 cursors

Author  Topic 

supersql
Yak Posting Veteran

99 Posts

Posted - 2008-07-10 : 12:39:26
How can work with store proc without using cursors?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-10 : 14:13:21
No use posting your entire code. just specify what you're trying to do here with some sample data. I'm sure people will find more easy to follow and help rather than reading and understanding this posted code.
Go to Top of Page

supersql
Yak Posting Veteran

99 Posts

Posted - 2008-07-10 : 14:21:07
Cursors are degrading performance in this case, am looking for a way without using cursors.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-10 : 14:36:27
quote:
Originally posted by supersql

Cursors are degrading performance in this case, am looking for a way without using cursors.


that we understood. But nobody will have time to read the full code and understand what its doing. thats why i suggested you to explain with some data what you're trying to do here so that we can provide soln without using cursors.
Go to Top of Page

supersql
Yak Posting Veteran

99 Posts

Posted - 2008-07-10 : 14:56:13
what am trying to do is

1.For the given auditid(parameter)am getting datefor that audit
2.GEt the id of the last audit for the given floorid
3.by that i'll get the previous audit information to the result set
4.then i'll get the current profile to add if any are missing

anyways here is the sample result set
AuditItemID,AuditItemName,IsGroupHeader,GroupHeaderHasItems,ZoneID, Score, InspectionItemId, Comment, ScoreTypeId, PreviousScore

657 | Conference Rooms | 1 |0 |1 |3.5 |1220606| |3 |3.5

658 Corridors and Hallways 1 1 2 NULL 0 3 NULL

898 Corridors and Hallways - Production 0 0 2 3 1220607 3 3

899 Elevators 0 0 2 3 1220608 3 3

897 Office 0 0 2 NULL 0 3 NULL

900 Stairwells 0 0 2 3 1220609 3 3
Go to Top of Page

supersql
Yak Posting Veteran

99 Posts

Posted - 2008-07-10 : 16:16:51
can i make use of CTE's here.
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2008-07-10 : 16:28:34
I see several tables in your cursor solution and only a result set above. Can you provide sample data (create and insert statements) so that we don't have to guess and/or make up sample data? As well as the expected output (which is what I think yoiu have listed above. Feel free to check the FAQ if you need more info on how to provide sample data.
Go to Top of Page

supersql
Yak Posting Veteran

99 Posts

Posted - 2008-07-10 : 16:44:37
I request u guys to check this post where i have given all the DML

http://www.sqlservercentral.com/Forums/Topic531281-338-1.aspx
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2008-07-10 : 17:21:13
You should guess that since you are not getting a usable solution from either this forum or from your post on sqlservercentral.com that your question is just not well formed. And the time it takes to understand your objective based on the posted code is just not worth the effort (at least for me).

What you posted on the other thread is just the DDL of the source tables.
You need to post:
- That DDL code here
- Some DML to populate those tables with sample data that can be used to generate your desired output.
- Inputs to your SP
- Desired output.
- If the rules to achieve your desired output is not obvious then please post a simple but complete explaination.

this isn't too bad for steps 1-3:
quote:

1.For the given auditid(parameter)am getting datefor that audit
2.GEt the id of the last audit for the given floorid
3.by that i'll get the previous audit information to the result set
4.then i'll get the current profile to add if any are missing


but for 4 I don't know what you mean by current profile and add what to what if any of what are missing?

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -