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
 Select Query...

Author  Topic 

john20
Starting Member

30 Posts

Posted - 2008-04-17 : 05:25:23
Hi All,

I want to retrive record from the table using select statement, which dosent contain "-" in the column value.
means i have record with "-" and without "-"
like

-12
23
-45
67
89

i want to retrive only
23
67
89

can u tell me how can i do that..

Thanks in advance.

Regards,
-John

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2008-04-17 : 05:42:19
Two options:

SELECT ColumnName FROM table WHERE ColumnName > 0

or

SELECT ColumnName FROM table WHERE SUBSTRING(ColumnName, 1, 1) <> '-'


--
Lumbago
Go to Top of Page

kfluffie
Posting Yak Master

103 Posts

Posted - 2008-04-17 : 06:12:12
quote:
Originally posted by Lumbago

Two options:

SELECT ColumnName FROM table WHERE ColumnName > 0

or

SELECT ColumnName FROM table WHERE SUBSTRING(ColumnName, 1, 1) <> '-'


--
Lumbago



It should be => before the 0 because you want to retrieve the 0 also, otherwise it will only retrive 1 and up.
SELECT ColumnName FROM table WHERE ColumnName => 0
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-04-18 : 04:28:21
quote:
Originally posted by john20

Hi All,

I want to retrive record from the table using select statement, which dosent contain "-" in the column value.
means i have record with "-" and without "-"
like

-12
23
-45
67
89

i want to retrive only
23
67
89

can u tell me how can i do that..

Thanks in advance.

Regards,
-John




Are you using INT datatype to store data?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -