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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 QRY

Author  Topic 

niranjankumark
Posting Yak Master

164 Posts

Posted - 2008-04-03 : 10:18:39
In a table one column has values as
0000012
0000214
0000000
000000
00000
0000
000
00
0

like if any number of zero available mean i shud show 0 .Here i shud display only 7. non zero exist mean i shud show.

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-04-03 : 10:20:58
Not clear what you mean. Maybe this?

Select cast(col as int) as col from table


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

Imukai
Starting Member

29 Posts

Posted - 2008-04-03 : 10:26:12
or SELECT CONVERT(int,columnname) FROM Table

If you wanted just the 0 ones then:

SELECT CONVERT(int,columnname) FROM Table
WHERE CONVERT(int,columnname) = 0
Go to Top of Page

niranjankumark
Posting Yak Master

164 Posts

Posted - 2008-04-03 : 10:31:05
In a table one column has values as
0000012
0000214
0000000
000000
00000
0000
000
00

.. RESULT SHUD SHOW AS

0
0
0
0
0
0
0

rows which is having more than 0 ( even one number ex : 0000012 ) it shud not display.

got it ????
ur qry will display
12
214
0
0
0
0
0
0
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-04-03 : 10:36:07
[code]Select case when col like '0%' then 0 else col end as col
from table[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page
   

- Advertisement -