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
 query question

Author  Topic 

sgraves
Starting Member

29 Posts

Posted - 2005-12-21 : 16:07:14
I am fairly new to this so I am still learning, but I have a question. I am trying to find a count in my SQL database. Is there anyway to get a count of all current dates for this year in the enterprise manager? When I open the table called 'license' and return all rows, I need to find "where clientno = '297' and issueddate = '05/00/00'. The problem I have is the dates vary like, 05/01/01, 05/04/15, 05/05/31, etc. Is there anyway to query all dates for 2005 with the client no of 297?

Thanks for any help.

Scott

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2005-12-21 : 16:22:07
start using query analyzer instead of enterprise manager for running queries.

what is the datatype of issuedate? if its not datetime or smalldatetime you'll need to do a string comparison. Is the format consistant (yy/mm/dd)? Maybe something like:

select <columnList>
from [license]
where clientno = 297
and issuedate like '00/%'


EDIT:
Do you know how to open a query analyzer window and switch to your database? Also, its a good idea to store your dates as actual datetime or smalldatetime datatypes. Otherwise they're pretty useless.

Be One with the Optimizer
TG
Go to Top of Page

sgraves
Starting Member

29 Posts

Posted - 2005-12-21 : 16:46:27
Yes, it is yy/mm/dd. I have never used query analyzer. How do I open it and do I type in what you have listed below?

Thanks for your help.

Scott
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2005-12-21 : 17:32:04
To launch QA, you should be able to click:
Start | Programs | Microsoft Sql Server | Query Analyzer

Once it's open:
File | Connect

complete the connection information

Once you're connected to your server then click the drop down combo box (top center) to select your database. You can type any t-sql statements into the main window and hit F5 or the green arrow to execute your statements.


Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -