Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am an amateur.

I am trying the following

select * from [dbo].[AccessFeeDetail]
where LastLoginDate >= '10/15/2012 00:00:00.000', jobname not like 'Uptest_%'

I am making a mistake on where clause. Can you correct me

"LastLoginDate" and "JobName" are Fields in the same table.

Thanks!

share|improve this question

closed as off-topic by Mark Sinkinson, Paul White Jan 5 at 7:29

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Too localized - this could be because your code has a typo, basic error, or is not relevant to most of our audience. Consider revising your question so that it appeals to a broader audience. As it stands, the question is unlikely to help other users (regarding typo questions, see this meta question for background)." – Mark Sinkinson, Paul White
If this question can be reworded to fit the rules in the help center, please edit the question.

up vote 6 down vote accepted

The comma , is not a valid logical operator. Try using AND or OR, depending on what you need, rows that match either one or both criteria (use OR) or only the rows that match both criteria (use AND).

You should also avoid writing dates with ambiguous formats, like the '10/15/2012 00:00:00.000'. Use either 2012-10-15T00:00:00.000 or '20121015 00:00:00.000' format. You can read Aaron Bertrand's blog for more details about dates and range queries: Bad habits to kick : mis-handling date / range queries. In this particular query and because the date has no time part, you can also use the shorter '20121015':

select * 
from [dbo].[AccessFeeDetail]
where LastLoginDate >= '20121015'
      AND 
      jobname not like 'Uptest_%' ;
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.