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.
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.
I think you want this
Select isnull(a, '') + ' X ' + isnull(b, '') from table1
Select isnull(a, '') + ' X ' + isnull(b, '') from table1
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 !!
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 !!
ASKER
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
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
ASKER
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 !!
Error converting data type varchar to float........i think need to convert second field?? how to write that...thanks !!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi
How can i include space b/w them??
like a x b ?? in the above query........??
How can i include space b/w them??
like a x b ?? in the above query........??
I don't know what you mean.