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)
 SQL statement help

Author  Topic 

nhaas
Yak Posting Veteran

90 Posts

Posted - 2007-03-06 : 19:43:38
I am trying to import data from Access into SQL 2000 and want to get everything except for a field that starts with WAS...Is it something like NOT like 'WAS%'

SELECT [LOC], [BU], [DIV], [KEY0], .....[TYPE] FROM [TESIS2] WHERE TYPE='CELL' or TYPTE='CELL' and [key0] NOT LIKE 'WAS%'

thanks for the help

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-03-06 : 19:56:30
Yes. Are you getting errors running the query?

Tara Kizer
Go to Top of Page

nhaas
Yak Posting Veteran

90 Posts

Posted - 2007-03-06 : 20:57:32
No errors, it just allows 'WAS 555-5555' and numbers like that to come through. I dont want to let any numbers that start with 'WAS ' to be saved into the database.

so I am getting all fields when I only want a select few. I was thinking that it might be that I am bringing it from access to SQL could this be the problem????

Thank You

SELECT [LOC], .....[TYPE] FROM [TESIS2] WHERE TYPE='CELL' or TYPE='CELL' and [key0] NOT LIKE 'WAS%'
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-03-06 : 21:00:06
[code]SELECT [LOC], [BU], [DIV], [KEY0], .....[TYPE]
FROM [TESIS2]
WHERE (TYPE='CELL' or TYPTE='CELL')
and [key0] NOT LIKE 'WAS%'[/code]


KH

Go to Top of Page

nhaas
Yak Posting Veteran

90 Posts

Posted - 2007-03-07 : 00:04:36
ah yes, thank you. It was something that I was missing. thanks for the help
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-03-07 : 01:12:17
It's called Operator Precedense.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

nhaas
Yak Posting Veteran

90 Posts

Posted - 2007-03-09 : 01:13:39
so the operator precedense is in the brackets (). Thanks

quote:
Originally posted by Peso

It's called Operator Precedense.


Peter Larsson
Helsingborg, Sweden

Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-03-09 : 01:19:10
Operator precedence will decide which operator will be evaluated first in a series of operators in the expression. In SQL, AND has higher precedence than OR.

To avoid this, we place OR expression inside parenthesis, so the expression will be evaluated before AND operator.

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

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-03-09 : 01:26:14
rule of thumb. Always use parenthesis () to define the operator evaluation priority. Don't rely on the default. Different language might have different operator precedence.


KH

Go to Top of Page
   

- Advertisement -