|
Posted by David Portas on 07/26/07 06:18
"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
--
[Back to original message]
|