OrElse
OrElse

Reputation: 9979

String Manipulation in SQL Server

Is there any way of setting an "Column Alias" in SQL Server?

For Example i have two columns. Description and Price

ID    colDescription                                colPrice
1     Red ball costs %colPrice% dollars             2
2     Blue ball costs %colPrice% dollars            3

The selection of colDescription for ID=2, should fetch

Blue ball costs 3 dollars

Upvotes: 0

Views: 291

Answers (2)

Keith Adler
Keith Adler

Reputation: 21178

You could use a Computed Column since you're on SQL Server 2005:

http://msdn.microsoft.com/en-us/library/ms191250.aspx

Upvotes: 0

Vinko Vrsalovic
Vinko Vrsalovic

Reputation: 340456

The manual way to do so would be:

select replace(coldescription,'%colPrice%',colprice) from table

Upvotes: 2

Related Questions