Showing posts with label xyz. Show all posts
Showing posts with label xyz. Show all posts

Sunday, February 19, 2012

IN versus =

Lets say i have a view

I select from that view with a where clause like

where xyz = 12

it takes 1 second to return

then i select the same view with xyz = 14

it takes 1 second to return

then i select from the view where

xyz in (12,14) why would it take 20 seconds for that data to come back if seperately it only took 2 seconds...

Check the execution plan. It may use Scan when you use in.|||

use OR instead of IN and post back the result.

select *from yourview where xyz=14 or xyz=12

and also tell us what all are the index on this table

Madhu

|||

You can compare the execution plans. The query optimizer use different strategy when dealing with the OR operator in the "where" clause. Sometimes it is better to use the "union all" of both separated statements.

select * from vw_v1 where xyz = 12

union all

select * from vw_v1 where xyz = 14

AMB

In SQL Server XYZ & xyz are treated as same value

Dear All,

In ORACLE, the values 'XYZ' and 'xyz' are treated as different values and I can enter two records with the primary key field having values 'XYZ' and 'xyz'.

But In SQL Server, 'XYZ' and 'xyz' or 'xYz' or 'Xyz' etc are treated as same value. So, when I try to insert 'xyz' after inserting a record with 'XYZ' as value of the primary key field, it gives me the duplicate record error. How to solve this problem?
I want it to work the SQL Server same as Oracle according to our requirement.

Can any one of you Please help me out in this regard?

Regards,
Sat.oracle is case sensitive, by default sql is not...
you can either change your whole installation to be case sensitive
or just make that primary key column case sensitive by running the command below...

alter table tablename
alter column columnname datatype
collate SQL_Latin1_General_Cp1_CS_AS