T-Sql rant

  • foxjazzG

    SSCrazy

    Points: 2221

    Why couldn't they write t-sql more like C# or have a flavored compiler for t-sql so that we could work it like c# or vb depending on how you like it. (or the t-sql language which really is the worst language MS has ever put on the block). I really don't understand why the sql server group didn't do a better job of it, or is it because they were taking thier queue from ORACLE.

    Really stupid paradigm if you ask me, and I think it needs to be improved upon.

  • John Rowan

    SSC Guru

    Points: 56440

    As it stands, T-SQL is about the most simple language on the planet. Specifically, what problems are you having that you feel are the languages fault?

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

  • Lynn Pettis

    SSC Guru

    Points: 442141

    So, what don't you like about T-SQL? I find it quite easy to work with and haven't had any problem moving from a 3GL language (COBOL) to it.

    The paradigm behind SQL (T-SQL) is completely different from working with a 3GL language but make total sense when working in a set oriented environment.

  • Steve Jones - SSC Editor

    SSC Guru

    Points: 715835

    T-SQL comes from SQL. It was developed by Sybase, not MS. It's similar to PL-SQL, which Oracle uses, but there are substantial differences.

    A query language, working with sets of data, is fundamentally different than a programming languages like C#.

    There are plenty of developers who think C# is a beast and a POS compared to other things. It's likely a preference thing. Each of us probably works with different types of languages and paradigms in different ways and prefers some.

    I, like the others, would be interested to know what specific issues you have.

  • GSquared

    SSC Guru

    Points: 260824

    OO Querying... what would it look like:

    Create Object qqMyQuery as Query;

    qqMyQuery.addtable.Table1;

    qqMyQuery.addtable.Table2;

    qqMyQuery.addtable.Table3;

    qqMyQuery.tables.addjoin(Type="Inner","Table1,Table2");

    qqMyQuery.tables.joins.addcriteria(Table1.Col1,Table2.Col2);

    And so on. Is something like that what you're looking for? Where you'd create objects based on definitions, and then would have to access methods and assign properties?

    Frankly, I don't think that works so well. If you really want to try it out, download the free trial of Cache. It's an OO DB. Instead of tables and columns, it has objects and properties. You can do things like "MyTable.Col1.value=1", instead of the T-SQL "update MyTable set Col1 = 1". Data storage is all multi-dimensional arrays. It's designed to work with .NET directly.

    If you don't like SQL, try it. Seriously.

    Personally, I've done so, and I'm sticking with SQL, for the simple reason that it's a LOT easier to build and operate a database in it. For me, anyway.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • foxjazzG

    SSCrazy

    Points: 2221

    are you guys living in the cage of t-sql? :)))

    well begin and end for one can be replace with { }

    declare @whatever as int can be replace with

    int @whatever

    gee I just shortened it by two whole words.

    set @i = 1 can be replaced by @i = 1 (which it has in sql 2008) about freaken time.

    Shall I go on, or can you get the idea?

  • foxjazzG

    SSCrazy

    Points: 2221

    also instead of using cursurs like they are now, wouldn't it be easier to say:

    foreach( select myfield from tbl where myotherfield > 3)

    {

    insert into myothertable (myotherfield) values (myfield)

    }

    I think it would be easier if this were the case. No GSquared, I like t-sql, but I think it could easily be made a lot more powerful if the t-sql guys would have just get off their asses and did something significant.

  • Lynn Pettis

    SSC Guru

    Points: 442141

    Your complaints are a bit of the mark IMHO. There is nothing wrong with the sematics of T-SQL. It's just different the C# just like C# is different from VB.NET or any of the other varied languages that exist in the world.

    Now, what really bothers you about SQL?

  • Lowell

    SSC Guru

    Points: 323392

    the only things you identified so far is a slight shortening of a couple of keywords....saving a handful of keystrokes doesn't mean that's an improvement, just a preference.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Lynn Pettis

    SSC Guru

    Points: 442141

    foxjazz (3/13/2009)


    also instead of using cursurs like they are now, wouldn't it be easier to say:

    foreach( select myfield from tbl where myotherfield > 3)

    {

    insert into myothertable (myotherfield) values (myfield)

    }

    I think it would be easier if this were the case. No GSquared, I like t-sql, but I think it could easily be made a lot more powerful if the t-sql guys would have just get off their asses and did something significant.

    Most of us SQL guys (and gals) don't use cursors to update tables. That is SO RBAR and inefficient in SQL Server.

  • andrewd.smith

    SSCrazy Eights

    Points: 8444

    If cursors were more convenient to use, you'd have people trying to use them even more than they currently do and destroying the performance of even more database servers.

  • Steve Jones - SSC Editor

    SSC Guru

    Points: 715835

    You're giving semantic differences. BEGIN and END function as {}. There's not difference. Honestly you could macro those to replace { with Begin if it's that important to you.

    Assignment of variables? I could see it being cleaner looking without DECLARE, but SQL doesn't really lend itself to constantly declaring and using variables like other languages. We do it, but not as often as we work with sets.

    Cursors don't make sense in SQL Server. They work better in Oracle. There has been discussion at times of how to improve/extend T-SQL from various sources. I think ForEach has been put out there, no idea of Sybase/MS will do it.

    There are differences. I typically would write:

    declare @i int

    , @j int

    No need for the AS. Same for aliases, though some people use AS. I think it depends how you've learned.

    For saving keystrokes, those keystrokes likely aren't buying you anything unless you think in sets. If you're programming in SQL like you do in C#, you're likely wasting lost of cycles and time by not adapting to the paradigm.

    I do think that in terms of tools and making development easier, SQL and it's interfaces (SSMS, etc.) are less mature than Visual Studio. Hopefully that will change.

  • foxjazzG

    SSCrazy

    Points: 2221

    I don't think it's my problem that sql server is so inefficient with the use of cursors. Maybe they should have designed sql server better eh?

    Yes shortening of stuff would be a lot better, lest junk to type, that is one of my biggest complaints.

  • andrewd.smith

    SSCrazy Eights

    Points: 8444

    Why couldn't they write t-sql more like C#

    With the introduction of the LINQ language extensions to C# 3.0, you could argue that C# is borrowing some of the syntax of SQL, so T-SQL can't be the antiquated dead end that you appear to be suggesting.

    I agree it's not that convenient for procedural tasks - that's not what T-SQL was designed for - but it's great for querying data sets.

  • Lynn Pettis

    SSC Guru

    Points: 442141

    foxjazz (3/13/2009)


    I don't think it's my problem that sql server is so inefficient with the use of cursors. Maybe they should have designed sql server better eh?

    Yes shortening of stuff would be a lot better, lest junk to type, that is one of my biggest complaints.

    If you like cursors so much, why not use ORACLE instead, it works well with cursors. MS SQL Server was developed to work well using sets, and it works quite well. It doesn't need to be optimized for working with cursors.

Viewing 15 posts - 1 through 15 (of 466 total)

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