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)
 Help with select statment

Author  Topic 

zoe_mcai9mh3
Starting Member

2 Posts

Posted - 2008-05-23 : 07:52:01
whats wrong with this statment?

declare @alpha as nvarchar(50)
set @alpha = select top 1 monthyear from dbo.Performance_Indicators_Rolling order by recordkey

I get an error

Incorrect syntax near the keyword 'select'.

Can anyone please help?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-05-23 : 07:53:56
quote:
Originally posted by zoe_mcai9mh3

whats wrong with this statment?

declare @alpha as nvarchar(50)
set @alpha = (select top 1 monthyear from dbo.Performance_Indicators_Rolling order by recordkey)

I get an error

Incorrect syntax near the keyword 'select'.

Can anyone please help?


Put braces around select
Go to Top of Page

zoe_mcai9mh3
Starting Member

2 Posts

Posted - 2008-05-23 : 08:01:02
Thats it!

Thanks
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-05-23 : 08:04:28
Or not use braces

select top 1 @alpha = monthyear from dbo.Performance_Indicators_Rolling order by recordkey



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -