Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

using a VALUE + a STRING as an ALIAS?

 
   Database Help (Home) -> Programming RSS
Next:  Scheduled DTS not working  
Author Message
Jerome

External


Since: Sep 14, 2005
Posts: 2



(Msg. 1) Posted: Fri Feb 23, 2007 11:45 am
Post subject: using a VALUE + a STRING as an ALIAS?
Archived from groups: microsoft>public>sqlserver>programming (more info?)

Hi,

I'd like to translate this from Access SQL to 'true' SQL:

SELECT "http:/mydomain/" & [Image] AS image_url

I've tried several things but SQL Server doesn't accept it.

How can I add this string to the value of that field?

Thank you very much!

Jerome

 >> Stay informed about: using a VALUE + a STRING as an ALIAS? 
Back to top
Login to vote
Tibor Karaszi

External


Since: Jan 29, 2004
Posts: 1559



(Msg. 2) Posted: Fri Feb 23, 2007 11:50 am
Post subject: Re: using a VALUE + a STRING as an ALIAS? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Change double quotes to single quotes. Also change & to +

SELECT 'hello' + colname AS image_url FROM ...

Be careful if the column allow NULL, which would result in the concatenated value being NULL (NULL
propagates). If you need to change that, take a look at functions such as ISNULL() and COALESCE().

--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/


"Jerome" wrote in message

> Hi,
>
> I'd like to translate this from Access SQL to 'true' SQL:
>
> SELECT "http:/mydomain/" & [Image] AS image_url
>
> I've tried several things but SQL Server doesn't accept it.
>
> How can I add this string to the value of that field?
>
> Thank you very much!
>
> Jerome

 >> Stay informed about: using a VALUE + a STRING as an ALIAS? 
Back to top
Login to vote
Jerome

External


Since: Sep 14, 2005
Posts: 2



(Msg. 3) Posted: Fri Feb 23, 2007 11:54 am
Post subject: Re: using a VALUE + a STRING as an ALIAS? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Thanks!


Tibor Karaszi wrote:
> Change double quotes to single quotes. Also change & to +
>
> SELECT 'hello' + colname AS image_url FROM ...
>
> Be careful if the column allow NULL, which would result in the concatenated value being NULL (NULL
> propagates). If you need to change that, take a look at functions such as ISNULL() and COALESCE().
>
 >> Stay informed about: using a VALUE + a STRING as an ALIAS? 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Way to alias a database? - Hi, I'm using MS Sql 2005. When I run a query from within "MyDatabase" that accesses another database, "OtherDatabase", is there a way I can create an alias, "OtherDatabaseOtherName", to access "OtherDatabase" so...

Table alias with UPDATE ? - Is there a way to use a table alias with an UPDATE that has no FROM clause? I'm using SQL 2000. For example: UPDATE TableLongName SET myfield3 = 789 WHERE TableLongName.myfield1 = 123 AND TableLongName.myfield2 = 456 works, but isn't as easy to read...

Using the field alias name in WHERE clause - Hi, Is there anyway to use the field alias name within the WHERE part of a SQL statement in MS SQL Server 2005? Below is an example: Select Table1.Name as FullName, Table1.Address as Address from Table1 Where FullName like '%test%' What..

using kind of alias in sqlplus - hi all. Can someone please help me on the following. Example query: Tabel1 contains a lot of items. TABLE1 ITEM VARCHAR2(30), FAM1 VARCHAR2(10), FAM2 VARCHAR2(10), FAM3 VARCHAR2(10), FAM4 VARCHAR2(10) Table contains a lot of records with....

Order by [alias] in 2005 issue - So this 'order by' works in SQL2000, but will error in 2005 - select top 1 a.forderID [orderId] from MyTable a order by a.orderid SQL2005 eRR: Msg 207, Level 16, State 1, Line 2 Invalid column name 'orderid'. How to work around? Is there a server...
   Database Help (Home) -> Programming All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]