Enrique Benito Casado
Enrique Benito Casado

Reputation: 2080

storing a unique value with Top is not posible Sybase

I wonder why i can not do that in sybase 15.5 My table is call "web_titles"

title_id is a varchar(6)

declare @idAux varchar(6)
set @idAux  = (select top 1 title_id from web_titles)

if i just do

select top 1 title_id from web_titles

return

title_id
-----------
PC8888

but if i try to set the variable i recive

Sybase error

"Incorrect syntax near the keyword 'top' "

I dont understand why. Any idee?

Upvotes: 1

Views: 37

Answers (2)

RobV
RobV

Reputation: 2378

TOP, ORDER BY and UNION are not allowed in subqueries in ASE

Upvotes: 1

Lukasz Szozda
Lukasz Szozda

Reputation: 176244

To assign value to variable you could use:

declare @idAux varchar(6);
select top 1 @idAux = title_id from web_titles;

Keep in mind that TOP 1 without ORDER BY is not reliable.

Upvotes: 1

Related Questions