Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between PL/SQL and T-SQL?

All that I know is that the former is Oracle and the latter is SQL Server. I assume some things might be easier in one versus the other but are there certain things I can do in PL that I can't in T?

Are there fundamental differences that I should be aware of? If so, what are they?

like image 841
Abe Miessler Avatar asked Mar 25 '11 04:03

Abe Miessler


3 Answers

T-SQL and PL/SQL are two completely different programming languages with different syntax, type system, variable declarations, built-in functions and procedures, and programming capabilities.

The only thing they have in common is direct embedding of SQL statements, and storage and execution inside a database.

(In Oracle Forms, PL/SQL is even used for client-side code, though integration with database-stored PL/SQL is (almost) seemless)

like image 123
devio Avatar answered Oct 15 '22 00:10

devio


The only fundamental difference is that PL/SQL is a procedural programming language with embedded SQL, and T-SQL is a set of procedural extensions for SQL used by MS SQL Server. The syntax differences are major. Here are a couple good articles on converting between the two:

  • http://www.dba-oracle.com/t_convent_sql_server_tsql_oracle_plsql.htm
  • http://jopinblog.wordpress.com/2007/04/24/oracle-plsql-equivalents-for-ms-sql-server-t-sql-constructs/
like image 31
Digitz Avatar answered Oct 15 '22 01:10

Digitz


They're not necessarily easier, just different - ANSI-SQL is the standard code that's shared between them - the SELECT, WHERE and other query syntax, and T-SQL or PL/SQL is the control flow and advanced coding that's added on top by the database vendor to let you write stored procedures and string queries together.

It's possible to run multiple queries using just ANSI-SQL statements, but if you want to do any IF statements or handle any errors, you're using more than what's in the ANSI spec, so it's either T-SQL or PL/SQL (or whatever the vendor calls it if you're not using Microsoft or Oracle).

like image 43
SqlRyan Avatar answered Oct 15 '22 00:10

SqlRyan