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
 hi All,

Author  Topic 

vishu.av
Starting Member

26 Posts

Posted - 2007-04-18 : 06:50:04
I am trying to use a 'string' column in where clause as below
example:
select * from MYTABLE where COLUMNNAME >= ''
Apparently COLUMNNAME is of varchar(12) datatype

My Problem is
The above query returns all the records in SQL Server 2000
where as
It returns NO ROWS in oracle 9i.
Please let me know how to return NO ROWS ( as in Oracle ) modifying
the query above in SQL server 2000

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-04-18 : 06:52:02
Why you are trying to do by this query? What is the purpose?

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

vishu.av
Starting Member

26 Posts

Posted - 2007-04-18 : 07:57:46
Hi,
I am working on a porting project ( oracle to SQL ).
I couldn't find equivalent query for not fetching me any rows when comparing with >= ''
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-04-18 : 08:03:30
It depends.
What are the data, and which records are you trying to fetch?


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

vishu.av
Starting Member

26 Posts

Posted - 2007-04-18 : 08:09:40
Hi Peter
Its just few rows of data that comprises of some varchar values and numeric ones.
Can you please let me know can i compare string like the one i am using above.
Select * from MyTable where ColumnName >= ''
--Column name can be a name of a person

Go to Top of Page

vishu.av
Starting Member

26 Posts

Posted - 2007-04-18 : 08:09:49
Hi Peter
Its just few rows of data that comprises of some varchar values and numeric ones.
Can you please let me know can i compare string like the one i am using above.
Select * from MyTable where ColumnName >= ''
--Column name can be a name of a person

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-04-18 : 08:15:09
Select * from MyTable where ColumnName > ''

to avoid select empty records over columnname


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

vishu.av
Starting Member

26 Posts

Posted - 2007-04-18 : 10:02:20
Hi Peter,
Thanks for the reply
I am afraid the Query above fetch indifferent results on SQL server and Oracle 9i.
Go to Top of Page

vishu.av
Starting Member

26 Posts

Posted - 2007-04-18 : 10:10:47
Hi Friends,
I got the clue.
Select * from MyTable where ColumnNames >= 'NULL' in SQL Server 2000 is same as
Select * from MyTable where ColumnNames >= '' in Oracle 9i
If we donot specify NULL in quotes the result is simply otherwise..
Thanks

vishu
Bangalore
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-04-18 : 10:17:09
What about this then?

declare @t table
(
a varchar(50)
)

insert @t
select 'xxx'

select * from @t where a >= 'NULL'


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

vishu.av
Starting Member

26 Posts

Posted - 2007-04-19 : 08:22:27
HI HARSH,
USE NULL WITHOUT SINGLE QUOTES, I GUESS IT SHOULD WORK.
THANKS


vishu
Bangalore
Go to Top of Page
   

- Advertisement -