Click here to Skip to main content
15,889,096 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
HELLO ,

HOW TO CONCAT STRING WITH TABLE NAME

LIKE..
SQL
SELECT

     User_Master.UserCode + 'EmailAddressInfo'

FROM User_Master


EmailAddressInfo Is a String
Posted
Updated 14-Nov-14 23:08pm
v3
Comments
King Fisher 15-Nov-14 5:09am    
with table Name Mean? how do u expect your Result ?
Maciej Los 15-Nov-14 5:37am    
Do not SHOUT!
Not sure what you want, but i'm almost sure you want to fetch data from table together with some text...

build your sql statement first and then execute it.
SQL
DECLARE @execquery AS NVARCHAR(MAX)
SET @execquery = N'SELECT User_Master.UserCode' + 'EmailAddressInfo' +' FROM User_Master'
EXEC(@execquery)
 
Share this answer
 
Comments
Manas Bhardwaj 15-Nov-14 5:42am    
Yes, +5!
Please, read my comment to the question.

I'd suggest to read this: T-SQL: + (String Concatenation)[^]

If UserCode field returns numeric values, you need to convert it to a varchar data type:
SQL
SELECT  CONVERT(VARCHAR(30), UserCode) + 'EmailAddressInfo' AS NewFieldName
FROM User_Master
 
Share this answer
 
Comments
Manas Bhardwaj 15-Nov-14 5:42am    
Yes, +5!
Maciej Los 15-Nov-14 5:44am    
Thank you, Manas ;)
King Fisher 15-Nov-14 5:45am    
i don't understand the Question .did u? :)
Maciej Los 15-Nov-14 5:55am    
As i mentioned in comment to the question, i'm not sure what OP wants to achieve, i can only guess...
King Fisher 15-Nov-14 6:07am    
ha ha ha :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900