converting integer to varchar and vice versa (Newbie)

H

harp

I have the following question:
I have a table with many rows among them rowA and rowB.
I would like to display rowB if it is not null otherwise I display
rowA. The problem is that rowB is of type varchar(50) and rowA is int
(4 in sqlserver 2000)

I have tried the following:
if([rowB] is not null;[rowB];[rowA])

If I run it, I get the an error like:
Datatypes in the criteria statement are not compartible

Any hints? how can I do the conversions to avoid the problem?

Thanks in anticipation
 
A

aaron.kempf

why don't you try using the same datatype?

if you're using SQL Server then you need to use a CAST or CONVERT
statement..

CONVERT(int, myvarcharfield)

try installing SQL Server 2000 Books Online; that should do the trick

-Aaron
 
H

harp

thanks Aaron!

why don't you try using the same datatype?

if you're using SQL Server then you need to use a CAST or CONVERT
statement..

CONVERT(int, myvarcharfield)

try installing SQL Server 2000 Books Online; that should do the trick

-Aaron

I have the following question:
I have a table with many rows among them rowA and rowB.
I would like to display rowB if it is not null otherwise I display
rowA. The problem is that rowB is of type varchar(50) and rowA is int
(4 in sqlserver 2000)

I have tried the following:
if([rowB] is not null;[rowB];[rowA])

If I run it, I get the an error like:
Datatypes in the criteria statement are not compartible

Any hints? how can I do the conversions to avoid the problem?

Thanks in anticipation
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top