You are here: Re: SQL HELP PLEASE!! Cursor only returns part of the data « MsSQL Server « IT news, forums, messages
Re: SQL HELP PLEASE!! Cursor only returns part of the data

Posted by Simon Barnett on 07/26/07 23:14

David,

I'm pretty basic with sql and thought that I needed a cursor but your
suggestion has worked.

Are cursors deemed as bad practice? Everyone I have spoken to says to
avoid them.

Many thanks
Simon

"David Portas" <REMOVE_BEFORE_REPLYING_dportas@acm.org> wrote in message
news:DeadnUdfnoYDoTXbRVnyhAA@giganews.com...
> "Simon Barnett" <sb@simonnospambarnett.com> wrote in message
> news:xARpi.21338$2U6.5520@fe1.news.blueyonder.co.uk...
>> Hi,
>>
>> I would much appreciate some help with a work project that is due very
>> soon.
>>
>> I have used a cursor to return the required result from a db table in
>> order for me to use in an ASP/VBScript webpage. This is the first time I
>> have used a cursor and am having problems.
>>
>
> Don't use a cursor. If you are inexperienced with SQL then it's better not
> to use cursors at all. Instead, always try for a single query solution.
> Find some examples to expand your knowledge of set-based SQL or get some
> advice and assistance.
>
> Here's my guess of what you intended. It's untested. If you had posted DDL
> and sample data I could have tested it out.
>
> SELECT KeyAccountability AS col1,
> 'keyacc' AS rowtype
> FROM KeyAccountability
> WHERE category = @var1
> AND jobprofileid = @jobprofileID
> UNION
> SELECT category AS col1,
> 'cat' AS rowtype
> FROM KeyAccountability
> WHERE category = @var1
> AND jobprofileid = @jobprofileID;
>
> --
> David Portas, SQL Server MVP
>
> Whenever possible please post enough code to reproduce your problem.
> Including CREATE TABLE and INSERT statements usually helps.
> State what version of SQL Server you are using and specify the content
> of any error messages.
>
> SQL Server Books Online:
> http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
> --
>
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация