Link to home
Start Free TrialLog in
Avatar of passion420
passion420

asked on

Concatenate 2 columns in sql server

I have two columns which i want to concatenate using sql query and later willl be using this query in vb.net to display two columns.

Select isnull(a, '') + '' +  isnull(b, '') from table 1

this displays the sum of these two columns in the result
However i want to display the columns as a X b and that should  be one column using code in vb.net.

Avatar of chapmandew
chapmandew
Flag of United States of America image

>>However i want to display the columns as a X b and that should  be one column using code in vb.net.

I don't know what you mean.
I think you want this
Select isnull(a, '') + ' X ' +  isnull(b, '') from table1
Avatar of passion420
passion420

ASKER

the above query is giving me some of two columns a+b i need to display these columns as aXb where X is just a letter and that should be displayed as one column as aXb in the query.

Also i will be using this query in my vb.net code later on so was just wondering if someone can provide me the equivalent code in vb.net that will be really helpful.

Thanks !!
sorry that is sum*  not some in the above comment
can you execute and try in sql server management studio
Select isnull(a, '') + ' X ' +  isnull(b, '') from table1
will actually display value in B X value in B  not the sum.
if you are looking for different output give some sample data
I am getting this error when executed the above said query:

Error converting data type varchar to float........i think need to convert second field?? how to write that...thanks !!
ASKER CERTIFIED SOLUTION
Avatar of udaya kumar laligondla
udaya kumar laligondla
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi

How can i include space b/w them??

like a  x  b ?? in the above query........??