Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Converting an INT value

Author  Topic 

gjc
Starting Member

2 Posts

Posted - 2010-12-09 : 04:27:33
I'm trying to convert a value from a field. Basically I have a priority field for records with a default value of 1000 but in certain cases I want to present this value as a 0 on an asp page. I don't want to change the value at all in the database. Any ideas would be welcome!
Many thanks.

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2010-12-09 : 04:47:02
Depends on how you retrieve it
If you want to do it in a select statement then

select Priority = case when priority = 1000 and <whatever else> then 0 else priority end
from ...

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2010-12-09 : 04:51:18
if it is only for display purpose you can do this.
select (column-column)from <table>.
this will make the value as 0.because iam substracting the value from the same column.
Go to Top of Page

gjc
Starting Member

2 Posts

Posted - 2010-12-09 : 04:59:08
Many thanks, I've done it with the case option.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-12-09 : 05:23:54
quote:
Originally posted by ahmeds08

if it is only for display purpose you can do this.
select (column-column)from <table>.
this will make the value as 0.because iam substracting the value from the same column.


That will be ZERO for every row / every value of [column], and not just when [column] = 1000

In which case you might just as well do

select 0 from <table>
Go to Top of Page

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2010-12-09 : 05:29:45
thanx for your reply.
but i wil filter the records in the where condititon.then how come it will affect all the rows.
Go to Top of Page
   

- Advertisement -