Endelm
asked on
SQL Variable - Result as SomeName
I have this query:
Create Mytable
(somefield int)
DECLARE @Num numeric (10,10)
SELECT top 1 @Num = somefield
from...
where...
I always get (No Column Name) when I get my result.
SELECT top 1 @Num = somefield as SomeCoolName // This doesn't work.
from...
where...
Any ideas?
Create Mytable
(somefield int)
DECLARE @Num numeric (10,10)
SELECT top 1 @Num = somefield
from...
where...
I always get (No Column Name) when I get my result.
SELECT top 1 @Num = somefield as SomeCoolName // This doesn't work.
from...
where...
Any ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SELECT top 1 SomeCoolName = YourField
from YourTable
OR another way to alias a field:
SELECT top 1 Field AS SomeCoolName
from YourTable