T-SQL may not be a 'true' programming language but it sure has lots of language features that make manipulating data possible. I spend quite a reasonable amount of time writing T-SQL scripts; either in production or learning or sometimes while teaching. While doing this I have often found myself cursing at the amount of typing required to accomplish otherwise simple constructs. Here is a sampling what I am rambling about:
1. Separation of variable declaration and initialization. Put simply, I would love to be able to do the following, at least for scalar types
DECLARE @var int=0
instead of having to do it over two lines, thus
DECLARE @var int
SET @var=0
2. Creating database objects using IF ..DROP..CREATE. It is just involves too many keystrokes. Oracle PL/SQL has the CREATE OR REPLACE syntax. Why wouldn't the SQL Server team indulge us on this one? For those who are wondering what this is all about, if you want to create a table, you must check if it exists before issuing the CREATE statement. You could go about it like this
IF OBJECT_ID('myTable') IS NOT NULL
DROP TABLE myTable
CREATE TABLE myTable(col1 int)
Please, just give us this instead
CREATE OR REPLACE TABLE myTable(col1 int)
If I am not mistaken, somebody has already asked for this on the Microsoft Connect site. You may want to vote for that feature.
3. Is there any hope for a more compact loop construct instead of this?
DECLARE @var int
SET @var=0
WHILE @var<1000
BEGIN
SET @var=@var+1
--Some code here
END
You notice that the six uncommented lines are required to do a simple loop. This can quickly increase if you have more than one loop (a.k.a an 'inner' loop). Since I don't expect to see curly brackets in T-SQL anytime soon, what about a FOR...NEXT simple VB-like loop?
I may come off as a truly lazy DBA, but after exposure to other 'programming' languages, I feel that once in a while my productivity is impaired with this chatful state of affairs. I am not sure if there is anything in the ANSI-SQL standard that prohibits these wishes from coming true, but I am definitely sure that the SQL Server programmability team should think about it.
Note To Self: If wishes were horses, beggars would surely ride.