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 2008 Forums
 Transact-SQL (2008)
 CONCAT FUNCTION NOT WORKING IN SQL 2008

Author  Topic 

Blessed1978
Yak Posting Veteran

97 Posts

Posted - 2015-02-19 : 17:09:25
When i run the below in sql 2008 it gives an error
however in 2012 it runs fine


'CONCAT' is not a recognized built-in function name.

how can a adjust this to work i sql 2008

CONCAT(CONCAT(empid , '@'),(SELECT SettingValue from SETTINGS WHERE Code = 'TEST'))

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2015-02-19 : 17:14:23
You can use + to concatenate in all of the versions. Here is an example:

select empid + '@' + settingvalue
from settings
where code = 'test'

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

Blessed1978
Yak Posting Veteran

97 Posts

Posted - 2015-02-19 : 17:56:52
when i run

select
[member_id] = e.empid + '@' + settingvalue from settings where code = 'test'

from employee e

error message

Msg 8114, Level 16, State 5, Line 1
Error converting data type varchar to bigint.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2015-02-19 : 19:10:17
Use CAST or CONVERT on the bigint column, which I assume is empid. You are concatenating it into a string, so it needs to be a string first.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
   

- Advertisement -