Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««2122232425»»»

T-Sql rant Expand / Collapse
Author
Message
Posted Wednesday, March 18, 2009 7:47 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, June 1, 2011 9:06 AM
Points: 56, Visits: 102
I feel Im running the risk of being lynched, but I agree in general with foxjaaz.

Im a database developer but I too am frustrated with the snail pace at which t-sql range and syntax has been ... well not really evolving.

Why cant t-sql be made to be more like a "modern" language, rather than some COBOL esque language that it is now. Why cant we declare constants, define packages, finer grained exception handling, autonomous transactions, basically most of whats already been in PL/SQL for years? Until 2008 you couldnt even declare and initaliase variables at the same time! You cant really blame people for looking at t-sql and thinking "how backward is this".

Why not get rid of some of the redundant syntax, C# did it by getting rid of the SET keyword, why not lose it in t-sql. Curly braces instead of BEGIN...END, sure why not?

At least give us a choice, so if you want to write COBOL, sorry T-SQL, or use perhaps a more familiar c# type syntax then let the writer choose. And expand t-sqls language constructs so I can do some "proper" development, without having to constantly bend the good coding rules because of limitations in t-sql.

Post #678464
Posted Wednesday, March 18, 2009 7:59 AM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Friday, June 27, 2014 12:43 PM
Points: 15,444, Visits: 9,596
kevin.reynolds (3/18/2009)
I feel Im running the risk of being lynched, but I agree in general with foxjaaz.

Im a database developer but I too am frustrated with the snail pace at which t-sql range and syntax has been ... well not really evolving.

Why cant t-sql be made to be more like a "modern" language, rather than some COBOL esque language that it is now. Why cant we declare constants, define packages, finer grained exception handling, autonomous transactions, basically most of whats already been in PL/SQL for years? Until 2008 you couldnt even declare and initaliase variables at the same time! You cant really blame people for looking at t-sql and thinking "how backward is this".

Why not get rid of some of the redundant syntax, C# did it by getting rid of the SET keyword, why not lose it in t-sql. Curly braces instead of BEGIN...END, sure why not?

At least give us a choice, so if you want to write COBOL, sorry T-SQL, or use perhaps a more familiar c# type syntax then let the writer choose. And expand t-sqls language constructs so I can do some "proper" development, without having to constantly bend the good coding rules because of limitations in t-sql.


I consider those legitimate complaints and suggestions, at least to one extent or another.

As for declaring constants, I use tables for that. After all, persisting data is something databases seem to manage pretty well.

Exception handling has been greatly improved in 2005 with Try...Catch, but it still does need some work. There needs to be a better way to insert error data into a table, even if you issue a rollback command.

Not sure what you mean by "autonomous transactions". Just not familiar with the term.

Like 2008 added declare and assign in one statement, perhaps some of these are just things that need to be requested often enough to make them worth building. MS does listen to such.


- 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
Post #678490
Posted Wednesday, March 18, 2009 8:08 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 9:33 PM
Points: 23,277, Visits: 31,997

kevin.reynolds (3/18/2009)
--------------------------------------------------------------------------------
I feel Im running the risk of being lynched, but I agree in general with foxjaaz.

Im a database developer but I too am frustrated with the snail pace at which t-sql range and syntax has been ... well not really evolving.

Why cant t-sql be made to be more like a "modern" language, rather than some COBOL esque language that it is now. Why cant we declare constants, define packages, finer grained exception handling, autonomous transactions, basically most of whats already been in PL/SQL for years? Until 2008 you couldnt even declare and initaliase variables at the same time! You cant really blame people for looking at t-sql and thinking "how backward is this".

Why not get rid of some of the redundant syntax, C# did it by getting rid of the SET keyword, why not lose it in t-sql. Curly braces instead of BEGIN...END, sure why not?

At least give us a choice, so if you want to write COBOL, sorry T-SQL, or use perhaps a more familiar c# type syntax then let the writer choose. And expand t-sqls language constructs so I can do some "proper" development, without having to constantly bend the good coding rules because of limitations in t-sql.




Because T-SQL is NOT C#, COBOL, or any other language of that type. SQL is a data access and manipulation language use to access data. It doesn't do the same things as C# or COBOL. Instead of complaining about the language, learn how to use it. You don't program in T-SQL the same way you program in C# or COBOL. You need to use a different mind set to write highly performant code in T-SQL.



Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #678499
Posted Wednesday, March 18, 2009 8:29 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 10:05 AM
Points: 2,897, Visits: 5,981
I get the whole declare then assign bit with variables, yes it's a pain, great that they finally did something about it in 2008. As for the SET Keyword, other than changing database and connection properties SET ANSI NULL on etc I never use it. I do all of my variable assignments using a SELECT Statement cause you can assign all of your varibales in one shot instead of bunch of separate SET Statements...

Don't even get me started on curly braces. I hate trying to read sets of nested {{{}{}}{{}{}}} cause some idiot thought they'd be slick and do it all on one line. They just all blend together when I look at them.

As was already stated in this thread if you make accommodations for C# developers in TSQL and make it more C# esque, who decides to use that convention and not VB, or Java or something else entirely? Do they include them all? What about ANSI SQL? Should we just throw that out cause it's not convenient? I'm sure all those fine folks working on the standard would just love that! I can hear Celko's rant already.

-Luke.


To help us help you read this

For better help with performance problems please read this
Post #678538
Posted Wednesday, March 18, 2009 8:29 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, February 18, 2014 7:14 AM
Points: 1,344, Visits: 1,983
kevin.reynolds (3/18/2009)
I feel Im running the risk of being lynched, but I agree in general with foxjaaz.

Im a database developer but I too am frustrated with the snail pace at which t-sql range and syntax has been ... well not really evolving.

Why cant t-sql be made to be more like a "modern" language, rather than some COBOL esque language that it is now. Why cant we declare constants, define packages, finer grained exception handling, autonomous transactions, basically most of whats already been in PL/SQL for years? Until 2008 you couldnt even declare and initaliase variables at the same time! You cant really blame people for looking at t-sql and thinking "how backward is this".

Why not get rid of some of the redundant syntax, C# did it by getting rid of the SET keyword, why not lose it in t-sql. Curly braces instead of BEGIN...END, sure why not?

At least give us a choice, so if you want to write COBOL, sorry T-SQL, or use perhaps a more familiar c# type syntax then let the writer choose. And expand t-sqls language constructs so I can do some "proper" development, without having to constantly bend the good coding rules because of limitations in t-sql.



One of the reasons why T-SQL may seem COBOL-esque is that the unbderlying core, SQL, is a standardized language, hence implementations should try to follow the standard. So the basic statements, SELECT, INSERT, UPDATE, DELETE, CREATE & DROP, have a clearly defined syntax and it make sense for extensions to follow a logical path from this. Hence, compared to a modern C-like language, it looks a bit COBOL-esque.

C# is simply a development by Microsoft, so whatever is done is the standard and they are free to add or drop keywords as they wish.

I don't see any reason to move towards C# and use {...} instead of BEGIN...END, since, in my view, there's little need for minor syntax changes that are mere eye-candy. I'd much rather see the effort going into features that actually change things, for example, the inclusion of the declare-with-assign in 2008.

Personally I'd like to see work done on making the optimizer better at, for example, handling User Defined Functions and recognizing where they might be expanded inline rather than actually called.


Derek
Post #678539
Posted Wednesday, March 18, 2009 8:35 AM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Sunday, August 17, 2014 3:10 PM
Points: 4,013, Visits: 6,098
Kevin:

Changes do get made and for the better. Constructive suggestions eventually get heard. I was really happy to see try/catch logic emerge, and CTEs, and inline table valued functions. Declare and assign in one line is kind of a yawner. Saves me a couple of keystrokes is all. Doesn't solve problems or improve performance. But change is good.

However, there is one thing I ask you guys to consider.

When you have a question in C#, you don't submit it to to a VB forum. Seems like you should be able to, the logic is the same. But most people are going to ignore your question because you are in the wrong place trying to speak the wrong language. SQL is doubly tricky because the logic isn't even the same. As of his last post, Fox still seemed to be struggling with the fundamentals.

You have a particular syntax in mind that you prefer. Easiest example is {} instead of Begin...End. I don't happen to care for {}, but I'm old school and everyone is entitled to a preference. There are other languages with different conventions. Should SQL support all those as well? I'm sure you don't care as long as it looks more like the various versions of C. Much like Americans who want the whole world to not only speak English, but to use the words from the American vocabulary.

Once you start saying that SQL must have syntax variations to read more like the various procedural languages, then the people who support SQL databases are going to have to fight through all the different variations. Code on one system, or from one vendor, might look very little like code somewhere else. This is a real problem. When books and documentation are written, which syntax will be used for the examples? When discussing code in forums like this, how much time would be wasted in translating? Are some vary knowledgeable people going to say "I only use the VB syntax, or SQL Classic. Go ask somebody else." Proliferation of tongues is an ancient curse. A lot of good thinking might be isolated just because of syntax.

Of course, there is an answer, or rather a question, when that happens.
If it gets you what you want, I suspect you would say to the DB heavies:

"Big deal. If you're going to do DB work, why can't you just suck it up and learn the different syntaxes?"

Good question.

It applies to you guys right now.


__________________________________________________

Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? -- Stephen Stills
Post #678547
Posted Wednesday, March 18, 2009 8:43 AM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Sunday, August 17, 2014 3:10 PM
Points: 4,013, Visits: 6,098
Now, back to business. Foxjazz is on the edge of enlightenment. I think we should cut the man some slack, because he has dropped the insults and started trying to cooperate. He was taught badly, and so learned bad habits, and we need to help unlearn him. So....

-------------------------------------------------------------------------
-- Pop Quiz for FOXJAZZ, just to make sure you are with us so far.
-- Based on what you have been shown, recode this as a set based solution
-- Hint#1: Anything with @ at the beginning must go.
-------------------------------------------------------------------------

create table #input (inputString varchar(100))
create table #output (outputString varchar(100))
insert into #input
select 'This is how we roll.' union all
select 'Just putting some strings in.' union all
select 'Setting up the problem and all that.' union all
select 'To make it easier for others to think about the problem.' union all
select 'Paradimethylaminobenzaldehyde '

----------------------------------------------------------------------------
-- Hint #2: everything between here and "select * from #output" can be
-- replaced with ONE line of code (whitespace)
-- or
-- two if you put the INSERT on a separate line for readability
-- or
-- three if you are excessive compulsive about putting a FROM
-- clause on its own separate line
-- or
-- seven, if you put every WORD on a separate line
----------------------------------------------------------------------------

declare @totallyUnnecessaryAndSuperfluousVariable varchar(100)
declare @sel cursor


----------------------------------------------------------------------------
-- ever notice how the loops for open-while-fetch all look alike?
-- wouldnt it be nice if you didnt have to fool with the boilerplate?
-- the fun part about programming is focusing on significant code
----------------------------------------------------------------------------

set @sel = cursor for
SELECT inputString from #input


open @sel
fetch next from @sel into @totallyUnnecessaryAndSuperfluousVariable

while (@@fetch_status = 0) -- so did we really read something or not?
begin
insert into #output (outputstring)
values(@totallyUnnecessaryAndSuperfluousVariable)
fetch next from @sel into @totallyUnnecessaryAndSuperfluousVariable -- didnt we do this already?
-- doesnt it seem silly to have to repeat it?
end



-------------------------------------
select * from #output

drop table #input
drop table #output



__________________________________________________

Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? -- Stephen Stills
Post #678555
Posted Wednesday, March 18, 2009 9:03 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 9:33 PM
Points: 23,277, Visits: 31,997
Bob, I'll join you in cutting foxjazz some slack, but there needs to be a bit more from him than just dropping the insults.

First, a simple apology for calling me dense would be a start.

Second, some actual recognition from him that we have shown that set based solutions exist for his cursor based processes and that they are actually more performant. At the moment, every time we solve a problem using a set based solution that he said could only be done using cursors and loops, he justs throws out another problem. No real recognition that there was a better solution.

Maybe, if the light bulb goes on, we'll finally get that.



Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #678585
Posted Wednesday, March 18, 2009 9:25 AM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Friday, April 4, 2014 3:57 PM
Points: 159, Visits: 317
Lynn, since you brought it up. I want to apologize for calling you dense.

It's been an adventure this week, I still don't have a computer from the recent crash and have only been able to remote into the server to get information.

That said, most of the problems I have encountered in the past has been with updates, not that many with inserts.

It seems that if I write a query like this:

declare @i int

select top 10 @i = @i + 1 , partnumber from prd

I shouldn't get an error. But hell what do I know.
Post #678619
Posted Wednesday, March 18, 2009 9:27 AM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Sunday, August 17, 2014 3:10 PM
Points: 4,013, Visits: 6,098
Understood, Lynn.

Fox, I do agree that you were out of line calling Lynn dense. He's a pretty bright guy who has helped a LOT of people. He is also patient to the point that some of us call him a saint. It wouldn't kill you to summon up a little humility and apologize.

By the way, the pop quiz is very important. This thread is not going to continue indefinitely. We are interested in teaching you how to do it right, not in rewriting all your code for you. You are paid to do that, and we are all volunteers with day jobs of our own.




__________________________________________________

Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? -- Stephen Stills
Post #678623
« Prev Topic | Next Topic »

Add to briefcase «««2122232425»»»

Permissions Expand / Collapse