urgent plz

  • can someone tell me whether my code works on SQL server database, thanks

     

    Select tblSales.FruitID,tblSales.Date,tblSales.Volume, tblSales.Price,

    TblFruit.FruitDescription from TblFruit INNER JOIN tblSales on TblFruit.FruitID = tblSales.FruitID where tblSales.date like ‘2001*’ and tblSales.FruitID in (‘4’,’5’,’7’);

    also any alternative way of selecting same results with date in 2001 !!

  • Select tblSales.FruitID,tblSales.Date,tblSales.Volume, tblSales.Price,

    TblFruit.FruitDescription from TblFruit INNER JOIN tblSales on TblFruit.FruitID = tblSales.FruitID where tblSales.date >= ‘2001/01/01’ AND tblSales.date < '2002/01/01' and tblSales.FruitID in (‘4’,’5’,’7’);

  • Why don't you test it yourself?

    -SQLBill

  • FYI - this poster had this to say in another thread:

    im oracle dba and applied for sql dba job and been given sql db questions, to answer and post it back havent got time to go through books and stuff, just quick, simple answer will do.

    never used sql db lol

    -SQLBill

  • i havent got sql server installed !!!and at this time im in hurry,!!!  its just the matter of syntax !!!!in access/oracle u may use distinct where in sql server u may use unique keyword ( just an example ), this is all what i want to double check mr SQL bill , the questions are sql server specific thats all, even in reall life someone who is good at sql can easy get away with sql syntax,

    why are u soo annoyed by my questions???

    do u really think a company will hire a dba who struggles? with writing select statment ?

    i never wish to be working for such a company !!!

    u got it now? by the way im one of the youngest oracle qualified dba !!!

    once u are professional dba it doesnt really matters whether u know about sql,sybase or oracle .... once u know the game u are done, ....

    does it feel any better now ?

    just havent got time and u waisting it

    bye

  • My problem is that the Books OnLine is downloadable. You are applying for a SQL Server DBA job and have posted LOTS of questions here. They are very basic SQL Server questions. You've shown us you aren't qualified for the job. Why should we help you get a job that you are not only unqualified for, but also not willing to do the work yourself?

    You say: once u are professional dba it doesnt really matters whether u know about sql,sybase or oracle .... once u know the game u are done, ....

    I don't agree. They are very different databases, as you are showing. And it's not a 'game'.

    Take the time to learn SQL Server and then apply for a job. Or at least put forth the effort to download the Books OnLine and find the answers.

    -SQLBill

  • Knowing the SQL syntax for basic queries doesn't prepare you for being a SQL Server DBA any more than it does for say... MySQL. The security structures are completely different. For that matter, the syntax between SQL Server 2000 and 2005 are completely different. Knowing how to add a user, manage roles, etc. in SQL Server does not give you the capability to do such in MySQL, Oracle, etc. And those are absolutely necessary DBA skills.

    SQL Server Express is downloadable and free. Time-limited editions of SQL Server are also downloadable. So there are plenty of opportunities to get up to speed on SQL Server (not just basic query syntax, but the whole works).

    If you are wondering why SQL Bill asked the question he did, read Steve Jones' latest article on 10 Ways to Lose Your DBA Job. That's the minimum expectation of most DBAs in industry... regardless of platform. Are you saying you're capable of doing all of the items he has listed for SQL Server? If so, you are in good stead for a SQL Server job. If you aren't, then you should consider getting more hands-on with SQL Server.

     

    K. Brian Kelley
    @kbriankelley

  • I'm agree with SQLBill

    Why don't you test it yourself?

    But Ok Sending U another simple way...

    SELECT

     tblSales.FruitID,

     tblSales.Date,

     tblSales.Volume,

     tblSales.Price,

     tblFruit.FruitDescription

    FROM

     tblFruit

     INNER JOIN tblSales

     ON TblFruit.FruitID = tblSales.FruitID

    WHERE

     YEAR(tblSales.date) = 2001

     AND tblSales.FruitID in ('4','5','7');

    BHUDEV PRAKASH

  • This, combined with Steve's article, all makes good material for a blog post.

    khoshtip, several members of the community have spoken, not to dissuade you from becoming a SQL Server DBA. Rather, our suggestion is to prepare yourself to succeed by getting more experience on the technology, especially since there are so many free resources. Hopefully the "criticism" has come across constructively to you. Being a SQL Server DBA can be a blast (just like Oracle, MySQL, DB2, etc.), however, it can really be depressing if you're not equipped for the challenges you'll face as one.

     

    K. Brian Kelley
    @kbriankelley

  • It's better to use the >= AND < operators for such a query.  You will lose any index seek chance if you use year(DateCol) = ...

  • First off you asked if your code would work. The answer is possibly but most likely will not return your expected results.

    For 1 the wildcard character for a LIKE in SQL Server for any replacement string is % not *.

    Secondly I would assume your DATE column is a DATETIME datatype and not a string so odds are you will get a syntax error around datetype conversion from string to datetime or the datetime column will convert to a string and not be in the right format for '2000%' to work.

    Also, personally I would use (4,5,6) and not ('4','5','6') unless the value is stored as a character type datatype. Otherwise the system will covert datatypes and may cause you not to get the best performance.

    You have seen several option examples but you should spend considerable time on the syntax (most of which isn't that far off from current Oracle syntax) and make sure you learn and understand the basics before you try for a job in SQL Server. It isn't hard but if you don't spend the time learning the basics it will cost you or someone else in the long run. As well, you should be able to answer the question using basic ANSI syntax which is the same in both systems. Just a polite suggestion.

  •  

    i havent got sql server installed !!!and at this time im in hurry,!!!  its just the matter of syntax !!!!in access/oracle u may use distinct where in sql server u may use unique keyword ( just an example ), this is all what i want to double check , the questions are sql server specific thats all, even in reall life someone who is good at sql can easy get away with sql syntax,

    why are u soo annoyed by my questions???

    do u really think a company will hire a dba who struggles? with writing select statment ?

    i never wish to be working for such a company !!!

     by the way im one of the youngest oracle qualified dba !!!

  • Not to mention possibly taking a job from a qualified SQL Server DBA that needs it.

    Besides t-sql is t-sql there are only simple differences between the syntax from SQL Server QA to Oracle t-SQL Editor. Download books online.

    Also if you do not understand what you are doing and the steps that should be taken before and after you could possibly hurt if not cripple this company if you got the job.

  • Maybe we should all just be happy that he didn't try to write the statement using cursors???

Viewing 14 posts - 1 through 13 (of 13 total)

You must be logged in to reply to this topic. Login to reply