Click here to Skip to main content
16,010,427 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to concatinate two feild if one is integer and other is varchar?????
how to write a query if i want comp_id feild from table?????


plz help me fast..
Posted
Updated 4-Jun-12 21:21pm
v2

SQL
select integer_column_name + varchar_columnname as Single_Field from Table_Name
 
Share this answer
 
v2
Try this:
C#
std::string name = "Prasad"; int age = 23;
std::string result;

// 1. with Boost
result = name + boost::lexical_cast<std::string xmlns:std="#unknown">(age).

// 2. with FastFormat.Format
fastformat::fmt(result, "{0}{1}", name, age);

// 3. with FastFormat.Write
fastformat::write(result, name, age);

// 4. with IOStreams
std::stringstream sstm;
sstm << name << age;
result = sstm.str();

// 5. with itoa
char numstr[21]; // enough to hold all numbers up to 64-bits
result = name + itoa(age, numstr, 10);

// 6. with sprintf
char numstr[21]; // enough to hold all numbers up to 64-bits
sprintf(numstr, "%d", age);
result = name + numstr;

// 7. with STLSoft's integer_to_string
char numstr[21]; // enough to hold all numbers up to 64-bits
result = name + stlsoft::integer_to_string(numstr, 21, age);

// 8. with STLSoft's winstl::int_to_string()
result = name + winstl::int_to_string(age);</std::string>
 
Share this answer
 
Comments
Linto Leo Tom 5-Jun-12 4:09am    
Good one +5
Prasad_Kulkarni 5-Jun-12 4:38am    
Thank you
codeBegin 5-Jun-12 5:44am    
My 5!
Manas Bhardwaj 5-Jun-12 5:55am    
Isn't this question tagged for ASP.Net? or I am missing something?
select cast(intcolumnname as varchar)+varcolumnname as concat from Tablename
 
Share this answer
 

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