dbTalk Databases Forums  

Re: SQl complex Stored Procedure using cursors

microsoft.public.sqlserver.server microsoft.public.sqlserver.server


Discuss Re: SQl complex Stored Procedure using cursors in the microsoft.public.sqlserver.server forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
--CELKO--
 
Posts: n/a

Default Re: SQl complex Stored Procedure using cursors - 09-01-2011 , 06:39 PM






Quote:
I’ve got a table, with an item
_type field [sic: columns are not fields]

Please be polite enough to post DDL, as required by Netiquette. You
also missed a basic term and do not follow ISO-11179 naming rules for
data elements.

Quote:
The value of this field [sic] is 1-6, and I’ve created 6 views based on this
field [sic], returning the same data set but from different fields
[sic] in the
table. Then I create a VIEW which is the UNION of these 6 views, see
below <<

UNIONs are pretty rare in a properly designed schema. Where is that
DDL?

Quote:
When I execute this in the SQL 2005 EM without the ‘item_nbr_description’ field [sic, and that needs to be a “<something>_item_nbr_description”], the 9 rows return in < 1 sec. If I include the item_nbr_description field [sic] (max len is 62 chars), it takes 4 secs to return the same 9 rows
Almost all of your data element names are useless and vague.
Item_what? vague_seq? Like a physical ordering? It also looks like you
actually modeled a physical line number from the paper forms in your
database! Why do you have all those silly Qry_Parts_Quote_Details_#
tables? SQL programmers and RDBMS hate repeated groups, split tables
and other forms of redundancy.

Also the idiom for a UNION is to name the columns in the alias:


SELECT X.*
FROM (SELECT parts_quote_id, line_nbr, vague_seq, item_nbr_type,
item_nbr, item_nbr_description
FROM Qry_Parts_Quote_Details_1
UNION
SELECT parts_quote_id, line_nbr, vague_seq, item_nbr_type,
item_nbr, item_nbr_description
FROM Qry_Parts_Quote_Details_2
..)
AS X(parts_quote_id, line_nbr, vague_seq, item_nbr_type,
item_nbr, item_nbr_description)
WHERE parts_quote_id = 2546;

Please try again.

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.