You are on page 1of 49

What are the similarity and differences between SQL Server 2000 and Oracle 8i (SQL Plus

)
19 Feb, 2004

What are the similarity and differences between SQL Server 2000 and Oracle 8i (SQL Plus) Which is the Best with vb 6.0 Hi sunil, Here is the diff 1. Oracle runs on many platforms, SQL on Windows only 2. Oracle includes IFS (Internet File System), Java integration, SQL is more of a pure database 3. Oracle requires client install and setup (Not difficult, but very UNIX-like for Windows users) 4. SQL is #1 in Cost/Performance and overall Performance, although Oracle will refute that 5. Replication is much easier in SQL (I have been at clients where even the Oracle consultant couldn't get it working w/oracle) 6. Failover support in SQL is much, much easier 7. JDBC support is much better in Oracle, although Microsoft is working on it 8. ODBC support in both 9. SQL is ANSI-SQL '92 compliant, making it easier to convert to another ANSI compliant database, theoretically anyway (truth is every database has proprietary extensions). Oracle is generally more proprietary and their main goal is to keep their customers locked-in. 10. SQL natively supports ODBC, OLEDB, XML, XML Query, XML updates. Oracle natively supports proprietary connections, JDBC. Not sure about XML support though. 11. SQL Server is much easier to administrate, with GUI and command- line tools. Most of Oracle is command-line (Back in SQL 6.5 days I had a customer who was so proud that after a day's worth of work he had managed to script his database. I showed him how it was a 3 click operation in SQL ;-) 12. Oracle requires add-ons for transaction monitors, failover, etc. SQL has COM+, uses NT clustering and generally has everything built-in 13. SQL Analysis Services is included (A very powerful OLAP server). For Oracle it is a separate purchase. Here is a brief comparison between Oracle 9i and SQL Server 2000. Platform dependancy SQL Server is only operable on the Windows platform, a major limitation for it to be an enterprise solution. Oracle is available on multiple platforms such as Windows, all flavors of Unix from vendors such as IBM, Sun, Digital, HP, Sequent, etc. and VAX-VMS, as well as MVS. The multiplatform nature of Oracle makes it a true enterprise solution. Locking and concurrency SQL Server has no multi-version consistency model, which means that "writers block readers and readers block writers" to ensure data integrity. In contrast, with Oracle, the rule is "readers don't block writers and writers don't block readers." This is possible without compromising data integrity because Oracle will dynamically recreate a read-consistent image for a reader of any requested data that has been changed but not yet committed. In other words, the reader will see the data as it was before the writer began changing it (until the writer commits). SQL Server's locking scheme is much simpler (less mature) and will result in a lot of delays/waits in a heavy OLTP environment. Also, SQL Server will escalate row locks to page level locks when too many rows on a page are locked. This locks rows which are uninvolved in any updates for no good reason. Performance and tuning a. In SQL Server, the DBA has no "real" control over sorting and cache memory allocation. The memory allocation is decided only globally in the server properties memory folder, and that applies for ALL memory and not CACHING, SORTING, etc. b. All pages (blocks) are always 8k and all extents are always 8 pages (64k). This means you have no way to specify larger extents to ensure contiguous space for large objects. c. No range partioning of large tables and indexes. In Oracle, a large 100 GB table can be seamlessly partitioned at the database level into range partitions. For example, an invoice table can be partitioned into monthly partitions. Such partitioned tables and partitioned indexes give performance and maintenance benefits and are transparent to the application. d. There is no partitioning in SQL Server. e. There are no bitmap indexes in SQL Server. f. There are no reverse key indexes in SQL Server. g. There are no function-based indexes in SQL Server. h. There is no star query optimization in SQL Server. Object types Here are some object types missing in SQL Server that exist in Oracle. a. You cannot declare public or private synonyms. b. There is no such thing as independent sequence objects. c. There are no packages; i.e., collections of procedures and functions. d. No "before" event triggers (only "after" event triggers) and no row triggers (only statement). e. No object types like in PL/SQL. PL/SQL versus T-SQL a. In T-SQL there are significant extensions to the ANSI SQL-92 standard which means converting applications to a different database later will be a code challenge re-write. The INNER JOIN, LEFT OUTER, RIGHT OUTER JOIN syntax differs from the classic JOIN. b. No Java database engine as in Oracle. c. Stored procedures in SQL Server are not compiled until executed (which means overhead, late binding and

finding errors at execution time only!). d. No ability to read/write from external files from a stored procedure. e. PL/SQL has many DBMS system packages, where T-SQL relies only on a limited number of extended and system stored procedures in the master database. f. PL/SQL is better in error exception handling, and there is no such thing as exceptions in T-SQL (T-SQL uses @@error -- not elegant!). g. TSQL does not have the MINUS operator, that makes finding schema differences more difficult in SQL Server. h. In SQL Server there is no "dead connection detection". Clients who lose their connection may still hold locks until a DBA is notified to kill their server side processes. i. In SQL Server there is no such thing as SQL*NET aliases/service names! This means applications have to hard code the actual server name into their apps, making it difficult to move databases later to load balance across servers. Clustering technology In clustering technology, Oracle is light years ahead, since SQL Server has nothing like Oracle Parallel Server/RAC -- two instances acting on the same data in active-active configurations. And with the new version of Parallel Server in Oracle 9i, renamed as the Oracle Real Application Clusters, there is diskless contention handling of read-read, read-write, write-read, and write-write contention between the instances. This diskless contention handling is called Cache Fusion, and it means for the first time, any application can be placed in a cluster without any changes, and it scales upwards by just adding another machine to the cluster. Microsoft has nothing like this. Reliability a. In SQL Server Standard Edition there is no ability to mirror the transaction log files. In Enterprise Edition there is a log shipping process that is not so reliable. b. If the logs fill up the disk, the database will crash hard. c. Sometimes this requires the server itself to be rebooted. Summary SQL Server is clearly positioned between Microsoft Access and Oracle in terms of functionality, performance and scalability. It is a good workgroup-level solution, a very quick time to market solution, and is very simple to use and administer. Oracle is much more advanced and has more to offer for larger applications with both OLTP and data warehouse applications. Its new clustering features are ideal for Application Service Providers (ASPs) on the Internet, who can now start with a cluster of two small servers and grow by just adding a server when they need to. It is always better to use SQL Server for Microsoft Technologies like VB6.0 Regards, Sashi.

29 Jun 05 04:06 AM : Asha R. T. : MCA working as a SE at Foxglove Softwares Blgr.
1. Oracle runs on many platforms, SQL on Windows only 2. Oracle includes IFS (Internet File System), Java integration, SQL is more of a pure database 3. Oracle requires client install and setup (Not difficult, but very UNIX-like for Windows users) 4. SQL is #1 in Cost/Performance and overall Performance, although Oracle will refute that 5. Replication is much easier in SQL (I have been at clients where even the Oracle consultant couldn't get it working w/oracle) 6. Failover support in SQL is much, much easier 7. JDBC support is much better in Oracle, although Microsoft is working on it 8. ODBC support in both 9. SQL is ANSI-SQL '92 compliant, making it easier to convert to another ANSI compliant database, theoretically anyway (truth is every database has proprietary extensions). Oracle is generally more proprietary and their main goal is to keep their customers locked-in. 10. SQL natively supports ODBC, OLEDB, XML, XML Query, XML updates. Oracle natively supports proprietary connections, JDBC. Not sure about XML support though. 11. SQL Server is much easier to administrate, with GUI and command- line tools. Most of Oracle is command-line (Back in SQL 6.5 days I had a customer who was so proud that after a day's worth of work he had managed to script his database. I showed him how it was a 3 click operation in SQL ;-) 12. Oracle requires add-ons for transaction monitors, failover, etc. SQL has COM+, uses NT clustering and generally has everything built-in 13. SQL Analysis Services is included (A very powerful OLAP server). For Oracle it is a separate purchase. 14. Oracle will be used especially in large database. But if we use sql server in such a environment, the data processing will become very slower. Oracle database very closely supports Java rather than Sql server. 15. Oracle 7 was RDBMS, i.e it was a relation database and the one's after that i.e. 8 onwards Oracle introduced the concept of OODBMS. Which stands for Object Oriented Database Management Systems. With every major release Oracle has initiated a lot of changes for the better. Like a. (1) Getting PL/SQL closer to ANSI SQL standards b. (2) Automatic Management of Undo from 9i onwards

c. (3) Introduction of special Grouping operators for queries d. (4) ISQL env for easier query processing e. (5) RAC (I dunno much about it) f. (6) AS(Application Server, integrated into the database) 16. SQL server GUI is easy to work. SQL serever is easy to maintain. Orcal data procssing is very good compared to SQL server 17. Oracle is like apple and Sql Server is like Orange. For a Poor man Orange is better and for a rich man apple is better.

SQL Server is usually easier to setup/configure, and get going - especially in terms of integrating into other Microsoft applications. Security is high in Oracle. And it will work fine in any environments like UNIX, SOLARIES OR WINDOWS-NT. Where as SQL SERVER performs more on WINDOWS-NT only. There are certain futures which one will miss, if he uses SQL SERVER without Windiws-NT server. What always amazes me is how many Oracle folks say SQL Server does not have this and that and our Oracle does all of this. Most of this is bullshit. The true is that many things can be accomplished differently in different databases and environments and it does not make sense to compare apples and oranges. Just to give you some ideas, when they say SQL server does not read/write files they forget to say that SQL Server does support extended stored procedures, using these procedures you can do file/write and virtually anything else that you can do in Windows and beyond. When they say SQL Server does not support Java, they forget to say that virtually nobody running SQL Servers wants to have slow and ugly Java (defeating the relational database concept) in their database and so on. This comparison is endless and has no real sense. Do not compare apples and oranges just because all of them are called fruits. I favour SQL Server for small quick business solutions on a budget, and Oracle for large scalable big budget solutions A few "corrections" from a long-time SQL Server user... - Bitmap indexing is rarely ever missed in SQL server, due to other indexing/optimizing techniques - Stored procedure plans are indeed retained in a compiled state, it is blatantly false to say that they are recompiled every time - Statistics are much easier to manage in SQL, but you can get far more fine-grained control in Oracle - Generally speaking, SQL query optimizer is far far more reliable in SQL; query hints are used rarely, if ever. That said, every database will have at least some optimizer glitches, and it is up to the database developer to discover and fix them (usually with hints) - Generally testing performance is easy in SQL, with easily accessible query plans and statistics. These can be obtained from Oracle but are much more challenging. Same for profile/trace of database activity. - Very generally speaking, SQL uses far less memory and performs noticably better out of the box than Oracle. But because of Oracle's fine-tuning capabilities, a *skilled* DBA can get better performance out of Oracle. - SQL can indeed do range partitioning, but it must be done manually (where I think for example DB2 can do it automatically by hash) - see "partitioned views"

Helpful wins for Oracle: - runs on *nix (for many, this ends the debate immediately) exception handling in pl/sql dialect - functon based indexes are occasionally very useful - but hard to rely upon (must write queries to exactly match the function usage) - can be heavily tuned for specific use cases; you rarely hit a dead-end optimizing oracle (if you have a very very skilled dba) - readers never block - standalone sequences are sometimes more useful than SQL IDENTITY - oracle supports more efficient constructs for fetching resultant data values during insert/update operations, and for advanced bulk operations Helpful wins for SQL: - runs great out of the box - free excellent management, profiling, monitoring tools - excellent query optimizer - rarely needs any tuning at all (but when you do, the options are few; wysiwyg) - included top-notch OLAP tool and full-text search; competitive with much more expensive solutions - much less memory and compute intensive (probably due to cheaper concurrency model and lighter configuration options!) - SQL also caches query plans of recent statements in an LRU cache - frequently used statements do not need recompiles, even without procedures Big difference: very different concurrency model between SQL and Oracle. Oracle operates against point-in-time(log) snapshots of the data (using SCNs), but acquires those on demand. Therefore readers never block. In SQL, you have more choices of isolation/concurrency, but the more aggressive settings will have writers block readers, and the most aggressive can have readers block writers. In classic RDBMS this is not too bad - but in complex deep relations such as OORDBMS-over-RDBMS or other object-graph storage solutions, deadlocks can really hurt your project unless you can scale some queries back to Read Committed isolation level. The article was written by Faulkner, Kent - USA and updated by Havewala, Porus Australia. 1. SINGLE PLATFORM DEPENDANCY SQL Server is only operable on the Windows platform, and this is a major limitation for it to be an enterprise solution. Oracle is available on multiple platforms such as Windows, all flavors of Unix from vendors such as IBM, Sun, Digital, HP, Sequent, etc. and VAX- VMS as well as MVS. The multi-platform nature of Oracle makes it a true enterprise solution. 2. LOCKING / CONCURRENCY SQL Server has no multi-version consistency model which means that "writers block readers and readers block writers" to ensure data integrity. In contrast, with Oracle the rule is "readers don?t block writers and writers don?t block readers". This is possible without compromising data integrity because Oracle will dynamically re-create a read-consistent image for a reader of any requested data that has been changed but not yet committed. In other words, the reader will see the data as it was before the writer began changing it (until the writer commits). SQL Server's locking scheme is much simpler (less mature) and will result in a lot ff delays/waits in a heavy OLTP environment.

Also, SQL Server will escalate row locks to page level locks when too many rows on a page are locked. This locks rows which are uninvolved in any updates for no good reason. 3. POTENTIAL OF LONG UNCOMMITED TRANSACTIONS HALTING DATABASE ACTIVITY In SQL Server 2000, a long uncommitted transaction can stop other transactions which queue behind it in the single transaction log, and this can stop all activity on the database, whereas in Oracle, if there is a long uncommitted transaction, only the transaction itself will stop when it runs out of rollback space, because of the use of different rollback segments for transactions. Oracle allocates transactions randomly to any of its multiple rollback segments and areas inside that rollback segment. When the transaction is committed, that space is released for other transactions, however Sql server allocates transactions sequentially to its single transaction log, the space occupied by committed transactions is not released to new transactions until the recycling of the transaction log is complete (in a circular round-robin manner). This means if there is an uncommitted transaction in the middle, and the transaction log cannot grow by increasing the file size, no new transactions will be allowed. This is the potential of a single uncommitted transaction to halt database activity. 4. PERFORMANCE and TUNING a. No control of sorting (memory allocation) in SQL Server. Oracle can fully control the sort area size and allows it to be set by the DBA. b. No control over SQL Caching (memory allocation) in SQL Server. This is controllable in Oracle. c. No control over storage/space management to prevent fragmentation in SQL Server. All pages (blocks) are always 8k and all extents are always 8 pages (64k). This means you have no way to specify larger extents to ensure contiguous space for large objects. In Oracle, this is fully configurable. d. No range partioning of large tables and indexes in SQL Server, whereas in Oracle a large table (eg. 100 GB or more) can be seamlessly partitioned at the database level into range partitions, for eg. an invoice table can be partitioned into monthly partitions. Such partitioned tables and partitioned indexes give performance and maintenance benefits and are transparent to the application. e. No Log miner facility in SQL Server. Oracle 8i and 9i supply a Log Miner which enables inspection of archived redo logs. This comes free with the database. But in the case of SQL Server, external products from other companies have to be purchased to do this important DBA task.

f. A SQL Server DBA claimed that fully qualifying the name of an object in SQL Server code would lead to performance gains of 7% to 10%. There are no dictionary performance problems like that in Oracle. Oracle would have some gains if it fully qualified all names - say 0.01 percent. This actually shows the difference in the internal database technology between Oracle and Microsoft and implies that the technology of resolving object names via the dictionary is more advanced in the case of Oracle, ie. Oracle seems to better access its internal dictionary and resolve names, unlike SQL server. 5. MISSING OBJECT TYPES IN SQL SERVER a. No public or private synonyms b. No independent sequences c. No packages ie. collection of procedures and functions. 6. PROGRAMMING a. Significant extensions to the ANSI SQL-92 standard in SQL Server, which means converting applications to a different database later will be a challenge (code rewrite). b. Sql Server has no inbuilt JAVA database engine as in Oracle. In Oracle, Java classes can be loaded and executed in the database itself, thus adding the database's security and scalability to Java applications. c. In SQL Server, stored Procedures are not compiled until executed (overhead). In Oracle, packages and procs/functions are compiled before execution. In Oracle 9i it is also possible to translate Pl/Sql into C code and then compile/link the code, which gives very good performance gains for numeric intensive operations. SQL Server has no such ability. d. In SQL server, there is no ability to read/write from external files from a stored procedure. Oracle has this ability. e. SQL Server uses cryptic commands for database administration like: exec sp_addrolemember N'db_datareader', N'davidb' go This is to add the user davidb to the role db_datareader. On the other hand, Oracle uses standard English-like SQL commands to do the same: grant db_datareader to davidb; This one statement does all, in simple English, what the cryptic SQL Server command does. f. Oracle SQL and PL/SQL syntax is more powerful and can do things more intuitively than Microsoft Transact-SQL. Try to sum up a column by each month, and

show the totals for the month, in SQL Server you do it in T-SQL by grouping on strings, in Oracle it is possible to do this grouping by the trunc(,'month') function. This method in Oracle is more intuitive, it understands the dates, the method in SQL Server does not. g. In SQL Server, you cannot issue a "create or replace" for either procedures or views, in Oracle you can. This one facility simplifies code writing, since in Sql Server the procedure or view must be dropped first if present and then recreated ie. two commands, in Oracle there is no need - a single command "create or replace" is enough. h. In Oracle, a procedure/function/package/view is marked as invalid if a dependant object changes. In SQL Server there is no concept of an invalid procedure, it will run but give unexpected results. The former is more suitable for change control and preventing unexpected errors. i. A recompile reuses the code that is in the Oracle database, the actual command is "alter procedure compile". This is applicable to procedures/functions/packages/views. This concept of recompiling is not there in SQL Server where you have to resubmit the whole code if you want to recompile a procedure. j. Triggers in Oracle do not allow transactional control ie. commit/rollback/savepoint statements. Whereas, triggers in SQL Server allow commits/rollbacks, which is potentially dangerous and can cause problems with transactions which fire the trigger. Triggers in SQL Server also can start transactions of their own which is not very good and shows lack of maturity of the language. 7. STANDBY DIFFERENCES SQL Server and Oracle have differences regarding standby databases. A standby is a database set up on a second server and to which logs are applied ie. all database changes, so that the standby can be activated and used in the case of a failover. a. In the case of Sql server, when there is a failover, the "master" and "msdb" databases have to be restored from backup or copied over from the primary to the standby and then the standby is activated after all logs are applied. In Oracle, there is no need for a restore to be done, the standby can be activated at any time after all logs are applied. This difference exists because of the fact that in SQL server, new users/roles added to the primary are not carried over to the standby (these users/roles go in the master/msdb) and backups have to be done continuously of the master and msdb, these backups are then restored when the time comes for a failover. In the case of Oracle, users/roles when created in the primary are automatically carried over to the standby. So when the failover time arrives, all that is needed is to activate the standby.

b. In the case of Sql Server, if the standby is opened as read only, to switch it back to standby again, a restore from backup has to be done. In the case of Oracle, from 8i version onwards, if a standby database is opened as read only, it can be reopened as a standby without restoring from backup. c. The time delay to apply logs between the primary and the standby can be varied, but it can never be 0 minutes in the case of SQL Server. In the case of Oracle, in 9i it is possible to have logs applied simultaneously to the primary as well as standby, using Net8 protocol. This means zero data loss in the case of a failover whereas SQL Server's log shipping cannot avoid data loss d during the time gap. d. SQL Server's log shipping mechanism also happens at the OS level, whereas Oracle's mechanism can take place directly at the Net8 level where logs are automatically applied to standbys without any scripts or OS batch files, this mechanism in Oracle is called managed standby. e.One deficiency of Oracle in the standby was that datafiles, if created on the primary, had to be manually created on the standby whereas SQL Server does this automatically. However, in 9i, this deficiency is fixed and data files are created automatically at the standby. f. Another deficiency of Oracle in the standby is that direct loads, if using the unrecoverable facility to bypass redo logging, require the data files of the primary database to be manually copied across to the standby. This is not fixed in 9i. SQL Server's version of log shipping and direct loads do not require this copying across. 8. CLUSTER TECHNOLOGY In clustering technology, in the case of SQL Server, two nodes cannot work on the same database, they "share nothing". At the best, to utilize the power of both nodes, the application must be manually spit up and redistributed between the hosts, working on different sets of data, and it is not possible to seamlessly scale upwards by adding another node to the cluster in the case of SQL Server. Most cluster configurations in Sql Server use the power of only one node, leaving the other node to take over only if there is a problem with the first node. In the case of Oracle Parallel server, it is possible to have two or more instances of the database on different nodes acting on the SAME data in active-active configurations. Lock management is handled by the Oracle Parallel server. With the new version of Parallel Server in Oracle 9i, renamed as the Oracle real application cluster (9i RAC), there is diskless contention handling of read-read, read- write, write-read, and writewrite contention between the instances. This diskless contention handling is called Cache Fusion and it means for the first time, any application can be placed in a cluster without any changes, and it scales upwards by just adding another machine to the cluster.

Microsoft has nothing like this clustering technology of Oracle, which can best be described as "light years ahead". 9. REPLICATION DIFFERENCES In Microsoft SQL Server's version of simple replication ie, publisher-subscriber using transactional replication, even if only one table is being replicated, the entire transaction log is checked by the log reader agent and transactional changes applied to the subscribers. In Oracle's simple replication, changes to a single table are stored in a snapshot log and copied across, there is no need to check all the archive logs. 10. SECURITY As of 2002, Oracle has 14 independent security evaluations; Microsoft SQL Server has only one. 11. INFORMATION POOL SQL Server and Internet articles of the magazine are only available with paid subscription. Whereas, Oracle has given its magazine free for many years, all articles are free on the internet, and the Oracle Technical network (OTN) is also free on the internet. 12. USABILITY Some people say Microsoft SQL Server tools, like Enterprise manager, are easy to use. Oracle Enterprise Manager is a huge tool and seems daunting to inexperienced people. This is true to an extent, however ease of use cannot be compared with the many features in Oracle, and its industrial-level strength, and its many technical advantages. 13. TCP Benchmarks March 2002 Benchmarks from TPC.org show that Oracle 9i is seen in the majority of top benchmarks in "non-clustered" TPC-C for performance (OLTP), whereas SQL Server is seen in the majority of entries for "clustered" TPC-C for performance (OLTP). This gives the strange impression that SQL server is faster in a cluster than in a noncluster, which is misleading. The fact is that this result is due to the use of "federated databases" in clusters by Microsoft in which pieces of the application are broken up and placed on separate active-active servers, each working on separate pieces of the application. While excellent for theoretical benchmarks, this is not a practical approach in the real life IT world because it requires massive changes to any application, and also ongoing changes to the application when new servers are added to the cluster (each server has a view that sees the data in the other servers, adding a new server would mean

rewriting the views for all tables on all servers) and would be rejected by any practical headed manager. Using this impractical approach of federated databases in clusters, the impression is that Sql-server leads in clustered performance, but the practical reality is otherwise. This is seen in the way SQL Server is not to be seen in the non-clustered benchmarks. Also, Oracle leads the way for Tpc benchmarks for Decision Support Systems with 1,000 Gb and 3,000 Gb sizes (TPC-H by performance per scale), whereas SQL Server is only seen to a small extent in the 300GB range. 14. XML Support To provide a more native support for XML, the first release of Oracle9i Database introduced the XMLType datatype and associated XML specific behavior. In addition, built in XML generation and aggregation operators greatly increase the throughput of XML processing. With the second release of Oracle9i, Oracle significantly adds to XML support in the database server. This fully absorbs the W3C XML data model into the Oracle database, and provides new standard access methods for navigating and querying XML - creating a native integrated XML database within the Oracle RDBMS. The key XDB technologies can be grouped into two major classes - XMLType that provides a native XML storage and retrieval capability strongly integrated with SQL, and an XML Repository that provides foldering, access control, versioning etc. for XML resources. The integration of a native XML capability within the database brings a number of benefits. In summation, Oracle9i Release 2's XDB functionality is a high- performance XML storage and retrieval technology available with the Oracle9i Release 2 database. It fully absorbs the W3C XML data model into the Oracle Database, and provides new standard access methods for navigating and querying XML. With XDB, you get all the advantages of relational database technology and XML technology at the same time. In contrast to this, Microsoft SQL Server 2000 only has limited ways to read and write xml from its tables. SUMMARY SQL Server is clearly positioned between MS-ACCESS and ORACLE in terms of functionality, performance, and scalability. It makes a work group level solution (small number of users with small amount of data), perhaps at the departmental level. Oracle is much more advanced and has more to offer for larger applications with both OLTP and Data Warehouse applications. Its new clustering features are ideal for Application Service Providers (ASPs) on the Internet who can now start with a cluster of 2 small servers and grow by just adding a server when they need to. Besides,

Oracle's multi-platform capability makes it the most convincing argument for an enterprise. Related links ? More about Oracle Tips & Ideas ? News by Administrator --------------------------------------------------------------------- ----------Most read story in Oracle Tips & Ideas: 127 Oracle DBA job interview questions Oracle versus Microsoft SQL Server 2000 comparission | Login/Create an account | 2 Comments Threshold -1 0 1 2 3 4 5 No comments Nested Flat Thread Oldest first Newest first Highest scores first Comments are owned by the poster. We aren't responsible for their content. Re: Oracle versus Microsoft SQL Server 2000 comparission (Score: 0) by Anonymous on Feb 18, 2003 - 10:15 AM I am a Project Manager who has worked on both SQLserver and Oracle projects in internet and standard LAN environments. My opinion is based on user perceptions of the databases and may have no justification technically, but they are what people are saying. Most users don't care what the database is. Often they will be a MS or Oracle shop and that's that, you wont change them. So usually there is no choice or even comparison of technologies, it's just "we have an Oracle licence, use it" and that's it. There is more to speed than the database. The raw grunt of the database is rarely a problem. You are far more likely to find speed issues that come from poor database design, crappy data models, slow networks, poor application architecture or just plain bad software design than from the actual speed of the database. When you get to the really high end, sure it matters, but the time and effort spent changing from RDBMS to the other to get extra speed (if there is any, and marginal at best) could be better spent on a gruntier box, you'll need one next year anyway. Once an MS shop, always an MS shop. MS has the "integration" of its products down pat. If you implement an MS solution from end-to-end, likely you will never get out. Their products are so dependent upon each other that to replace one component is just too hard. You can build similar implementations in Oracle by embedding logic in the database, but you don't have to. Oracle is far more OPEN to different clients and platforms. If you want an SQLserver system to run at optimal performance, it's MS end- to-end. Robert Green Software Developer, Consulting/Systems Integrator Re: Oracle versus Microsoft SQL Server 2000 comparission (Score: 0) by Anonymous on Feb 19, 2003 - 10:23 AM SQL Server is a joke With all the hype, MSFT still can't keep locks from escalating and DB reads clean. Until MSFT, SYBS, and IBM do so they will not be taken seriously in the high OLTP world demanded by the web.

Check the stats, 10 of the top 10 web sites in the world use Oracle. As far as the TPC benchmarks are concerned, IBM and MSFT are using smoke and mirrors. It took TWELVE separate databases to be only twice as fast as ONE Oracle database. Oracle has been able to use federations of databases (used by MSFT and IBM) for benchmarks for five years. Oracle could beat IBM numbers 10 times over using a federation, but won't because any real DBA would never consider using this useless configuration in a real situation. Shared disk is the cluster configuration of every major system on the web, MSFT, IBM and everybody else can't yet do it so they use Shared nothing, which is good for just that, NOTHING. If you buy into the hype, be sure to keep your receipt! by vikram lashkari -- Vikram Lashkari (vikram_lashkari@yahoo.com), April 20, 2004. Thank you all for these great answers, I have been looking for a succinct precis like this for a while, you have saved me much wading through sales material. -- Martin Lang (martin.lang@mail.com), April 22, 2004. I have a very specific comparison between both the DB. If u need to update multiple column with the condition in Oracle it is possible but same thing is not possible at SQL server. Ex: update emp set (empname,sal)=( select empname,sal from emp where empcode=10000) -- Arun Kumar (arkumar74@hotmail.com), April 26, 2004. in both you have procedural langage but: a) oracle , you can catch exception where you want, even a the end of procedure and then trapping all cases. b) sql2000, yu need to write your own code AFTER EACH statement, heavy, heavy,heavy. -- bruno delaunay (bdelaunay@lovefrance.fr), May 31, 2004. Oracle is best perfomance rather than SQL Server... -- Alim (affanbsc@yahoo.com), June 04, 2004. this is some good stuff. i learnt a lot ,thanx. -- xyzstarr (thato@info4africa.info), July 02, 2004. SQL Server 2000 only works on Windows-based platforms, including Windows 9x, Windows NT, Windows 2000 and Windows CE. In comparison with SQL Server 2000, Oracle 9i Database supports all known platforms, including Windows-based platforms, AIX-Based Systems, Compaq Tru64 UNIX, HP 9000 Series HP-UX, Linux Intel, Sun Solaris and so on.

It is very difficult to make the performance comparison between SQL Server 2000 and Oracle 9i Database. The performance of your databases depends rather from the experience of the database developers and database administrator than from the database's provider. You can use both of these RDBMS to build stable and efficient system. However, it is possible to define the typical transactions, which used in inventory control systems, airline reservation systems and banking systems. After defining these typical transactions, it is possible to run them under the different database management systems working on the different hardware and software platforms. Both SQL Server 2000 and Oracle 9i Database support the ANSI SQL-92 entry level and do not support the ANSI SQL-92 intermediate level. In the Features comparison section of this article I want to make the brief comparison of the TransactSQL with PL/SQL and show some SQL Server 2000 and Oracle 9i Database limits. SQL Server 2000 vs Oracle 9i Alexander Chigrik chigrik@mssqlcity.com --------------------------------------------------------------------- ----------Introduction Platform comparison Hardware requirements Software requirements Performance comparison TPC tests Price comparison Features comparison T-SQL vs PL/SQL SQL Server 2000 and Oracle 9i limits Conclusion Literature --------------------------------------------------------------------- ----------Introduction Often people in newsgroups ask about some comparison of Oracle and Microsoft SQL Server. In this article, I compare SQL Server 2000 with Oracle 9i Database regarding price, performance, platforms supported, SQL dialects and products limits. Platform comparison SQL Server 2000 only works on Windows-based platforms, including Windows 9x, Windows NT, Windows 2000 and Windows CE. In comparison with SQL Server 2000, Oracle 9i Database supports all known platforms, including Windows-based platforms, AIX-Based Systems, Compaq Tru64 UNIX, HP 9000 Series HP-UX, Linux Intel, Sun Solaris and so on. Hardware requirements To install SQL Server 2000, you should have the Intel or compatible platforms and the following hardware: Hardware Requirements Processor Pentium 166 MHz or higher Memory 32 MB RAM (minimum for Desktop Engine), 64 MB RAM (minimum for all other editions), 128 MB RAM or more recommended Hard disk space 270 MB (full installation), 250 MB (typical), 95 MB (minimum), Desktop Engine: 44 MB Analysis Services: 50 MB minimum and 130 MB typical English Query: 80 MB Oracle 9i supports Intel or compatible platforms, AIX-Based Systems, Compaq Tru64 UNIX, HP 9000 Series HP-UX, Linux Intel, Sun Solaris and so on. To install Oracle 9i under the Intel or compatible platforms, you should have the following hardware:

Hardware Requirements Processor Pentium 166 MHz or higher Memory RAM: 128 MB (256 MB recommended) Virtual Memory: Initial Size 200 MB, Maximum Size 400 MB Hard disk space 140 MB on the System Drive plus 4.5 GB for the Oracle Home Drive (FAT) or 2.8 GB for the Oracle Home Drive (NTFS) To install Oracle 9i Database under the UNIX Systems, such as AIX- Based Systems, Compaq Tru64 UNIX, HP 9000 Series HP-UX, and Sun Solaris, you should have the following hardware: Hardware Requirements Memory A minimum of 512 MB RAM Swap Space A minimum of 2 x RAM or 400 MB, whichever is greater Hard disk space 4.5 GB Software requirements SQL Server 2000 comes in six editions: Enterprise, Standard, Personal, Developer, Desktop Engine, and SQL Server CE (a compatible version for Windows CE) and requires the following software: Operating System Enterprise Edition Standard Edition Personal Edition Developer Edition Desktop Engine SQL Server CE Windows CE No No No No No Yes Windows 9x No No Yes No Yes No Windows NT 4.0 Workstation with Service Pack 5 No No Yes Yes Yes No Windows NT 4.0 Server with Service Pack 5 Yes Yes Yes Yes Yes No Windows NT 4.0 Server Enterprise Edition with Service Pack 5 Yes Yes Yes Yes Yes No Windows 2000 Professional No No Yes Yes Yes No Windows 2000 Server Yes Yes Yes Yes Yes No Windows 2000 Advanced Server Yes Yes Yes Yes Yes No Windows 2000 DataCenter Yes Yes Yes Yes Yes No Windows XP Professional No No Yes Yes Yes No Oracle 9i Database comes in three editions: Enterprise, Standard and Personal and requires the following software: Platform Operating System Version Required Patches Windows-based Windows NT 4.0 Service Pack 5 Windows-based Windows 2000 Service Pack 1 Windows-based Windows XP Not Necessary AIX-Based AIX 4.3.3 Maintenance Level 09 and IY24568, IY25282, IY27614, IY30151 AIX-Based AIX 5.1 AIX 5L release 5.1 ML01+ (IY22854), IY26778, IY28766, IY28949, IY29965, IY30150 Compaq Tru64 UNIX Tru64 5.1 5.1 patchkit 4 Compaq Tru64 UNIX Tru64 5.1A 5.1A patchkit 1 HPUX HP-UX version 11.0 (64-bit) Sept. 2001 Quality Pack, PHCO_23792, PHCO_24148, PHKL_24268, PHKL_24729, PHKL_ 25475, PHKL_25525, PHNE_24715, PHSS_23670, PHSS_24301, PHSS_24303, PHSS_24627, PHSS_22868 Linux SuSE Linux Enterprise Server 7 (or SLES-7) with kernel 2.4.7, and glibc 2.2.2 Not Necessary Sun Solaris Solaris 32-Bit 2.6 (5.6), 7 (5.7) or 8 (5.8) Not Necessary Sun Solaris Solaris 64-Bit 8 (5.8) Update 5 Performance comparison It is very difficult to make the performance comparison between SQL Server 2000 and Oracle 9i Database. The performance of your databases depends rather from the experience of the database developers and database administrator than from the database's provider. You can use both of these RDBMS to build stable and efficient system. However, it is possible to define the typical transactions, which used in inventory control systems, airline reservation systems and banking systems. After defining these typical transactions, it is possible to run them

under the different database management systems working on the different hardware and software platforms. TPC tests The Transaction Processing Performance Council (TPC.Org) is independent organization that specifies the typical transactions (transactions used in inventory control systems, airline reservation systems and banking systems) and some general rules these transactions should satisfy. The TPC produces benchmarks that measure transaction processing and database performance in terms of how many transactions a given system and database can perform per unit of time, e.g., transactions per second or transactions per minute. The TPC organization made the specification for many tests. There are TPC-C, TPCH, TPC-R, TPC-W and some old tests, such as TPC-A, TPC-B and TPC-D. The most popular test is the TPC-C test (OLTP test). At the moment the article was wrote, SQL Server 2000 held the top TPC-C by performance results with Distributed Partitioned Views- based cluster systems. See Top Ten TPC-C by Performance Version 5 Results At the moment the article was wrote, SQL Server 2000 held the top TPC-C by price/performance results. See Top Ten TPC-C by Price/Performance Version 5 Results Note. Because most organizations really do not run very large databases, so the key points on which SQL Server 2000 won the TPC-C benchmarks do not really matter to the vast majority of companies. Price comparison One of the main Microsoft SQL Server 2000 advantage in comparison with Oracle 9i Database is that SQL Server is cheaper. Other SQL Server advantage is that Microsoft includes the Online analytical processing (OLAP) and Data Mining as standard features in SQL Server 2000 Enterprise Edition. So, you can save up to four times with SQL Server 2000 Enterprise Edition if you use OLAP and Data Mining. The price comparisons below were based on the Oracle and SQL Server 2000 Price Comparison article from Microsoft. Compare pricing for SQL Server 2000 Standard Edition and Oracle9i Standard Edition: Number of CPUs Oracle9i Standard Edition SQL Server 2000 Standard Edition 1 $15,000 $4,999 2 $30,000 $9,998 4 $60,000 $19,996 8 $120,000 $39,992 16 $240,000 $79,984 32 $480,000 $159,968 Compare pricing for SQL Server 2000 Enterprise Edition (which include OLAP and Data Mining) and Oracle9i Enterprise Edition with OLAP and/or Data Mining: Number of CPUs Oracle9i Enterprise Edition Oracle9i Enterprise Edition with OLAP or Data Mining Oracle9i Enterprise Edition With OLAP and Data Mining SQL Server

2000 Enterprise Edition 1 $40,000 $60,000 $80,000 $19,999 2 $80,000 $120,000 $160,000 $39,998 4 $160,000 $240,000 $320,000 $79,996 8 $320,000 $480,000 $640,000 $159,992 16 $640,000 $960,000 $1,280,000 $319,984 32 $1,280,000 $1,920,000 $2,560,000 $639,968 Note. This is not a full price comparison between SQL Server 2000 and Oracle 9i Database. It is only a brief comparison. You can have any discounts and the prices can be increased or decreased in the future. See Microsoft and Oracle to get more information about the price of their products. Features comparison Both SQL Server 2000 and Oracle 9i Database support the ANSI SQL-92 entry level and do not support the ANSI SQL-92 intermediate level. In the Features comparison section of this article I want to make the brief comparison of the Transact-SQL with PL/SQL and show some SQL Server 2000 and Oracle 9i Database limits. T-SQL vs PL/SQL The dialect of SQL supported by Microsoft SQL Server 2000 is called Transact-SQL (T-SQL). The dialect of SQL supported by Oracle 9i Database is called PL/SQL. PL/SQL is more powerful language than T- SQL -- Narayana Reddy P (narayana_395@yahoo.co.in), July 03, 2004. Difference between Oracle and SQL 2000 Introduction In this article, I compare SQL Server 2000 with Oracle 9i Database regarding price, performance, platforms supported, SQL dialects and products limits. Platform comparison SQL Server 2000 only works on Windows-based platforms, including Windows 9x, Windows NT, Windows 2000 and Windows CE. In comparison with SQL Server 2000, Oracle 9i Database supports all known platforms, including Windows-based platforms, AIX-Based Systems, Compaq Tru64 UNIX, HP 9000 Series HP-UX, Linux Intel, Sun Solaris and so on. Hardware requirements To install SQL Server 2000, you should have the Intel or compatible platforms and the following hardware: Hardware Requirements Processor Pentium 166 MHz or higher Memory 32 MB RAM (minimum for Desktop Engine),64 MB RAM (minimum for all other editions),128 MB RAM or more recommended Hard disk space 270 MB (full installation),250 MB (typical),95 MB (minimum),Desktop Engine: 44 MBAnalysis Services: 50 MB minimum and 130 MB typicalEnglish Query: 80 MB Oracle 9i supports Intel or compatible platforms, AIX-Based Systems, Compaq Tru64 UNIX, HP 9000 Series HP-UX, Linux Intel, Sun Solaris and so on. To install Oracle 9i under the Intel or compatible platforms, you should have the following hardware: Hardware Requirements Processor Pentium 166 MHz or higher Memory RAM: 128 MB (256 MB recommended)Virtual Memory: Initial Size 200 MB, Maximum Size 400 MB Hard disk space 140 MB on the System Driveplus 4.5 GB for the Oracle Home Drive (FAT)or 2.8 GB for the Oracle Home Drive (NTFS)

To install Oracle 9i Database under the UNIX Systems, such as AIX- Based Systems, Compaq Tru64 UNIX, HP 9000 Series HP-UX, and Sun Solaris, you should have the following hardware: Hardware Requirements Memory A minimum of 512 MB RAM Swap Space A minimum of 2 x RAM or 400 MB, whichever is greater Hard disk space 4.5 GB Software requirements SQL Server 2000 comes in six editions: Enterprise, Standard, Personal, Developer, Desktop Engine, and SQL Server CE (a compatible version for Windows CE) and requires the following software: Operating Enterprise Standard Personal Developer Desktop SQL Server System Edition Edition Edition Edition Engine CE Windows CE No No No No No Yes Windows 9x No No Yes No Yes No Windows NT 4.0 Workstation with Service Pack 5 No No Yes Yes Yes No Windows NT 4.0 Server with Service Pack 5 Yes Yes Yes Yes Yes No Windows NT 4.0 Server Enterprise Edition with Service Pack 5 Yes Yes Yes Yes Yes No Windows 2000 Professional No No Yes Yes Yes No Windows 2000 Server Yes Yes Yes Yes Yes No Windows 2000 Advanced Server Yes Yes Yes Yes Yes No Windows 2000 DataCenter Yes Yes Yes Yes Yes No Windows XP Professional No No Yes Yes Yes No Performance comparison It is very difficult to make the performance comparison between SQL Server 2000 and Oracle 9i Database. The performance of your databases depends rather from the experience of the database developers and database administrator than from the database's provider. You can use both of these RDBMS to build stable and efficient system. However, it is possible to define the typical transactions, which used in inventory control systems, airline reservation systems and banking systems. After defining these typical transactions, it is possible to run them under the different database management systems working on the different hardware and software platforms. TPC tests The Transaction Processing Performance Council (TPC.Org) is independent organization that specifies the typical transactions (transactions used in inventory control systems, airline reservation systems and banking systems) and some general rules these transactions should satisfy. The TPC produces benchmarks that measure transaction processing and database performance in terms of how many transactions a given system and database can perform per unit of time, e.g., transactions per second or transactions per minute. The TPC organization made the specification for many tests. There are TPC-C, TPCH, TPC-R, TPC-W and some old tests, such as TPC-A, TPC-B and TPC-D. The most popular test is the TPC-C test (OLTP test).

At the moment the article was wrote, SQL Server 2000 held the top TPC- C by performance results with Distributed Partitioned Views-based cluster systems. See Top Ten TPC-C by Performance Version 5 Results At the moment the article was wrote, SQL Server 2000 held the top TPC- C by price/performance results. See Top Ten TPC-C by Price/Performance Version 5 Results Note. Because most organizations really do not run very large databases, so the key points on which SQL Server 2000 won the TPC-C benchmarks do not really matter to the vast majority of companies. Price comparison One of the main Microsoft SQL Server 2000 advantage in comparison with Oracle 9i Database is that SQL Server is cheaper. Other SQL Server advantage is that Microsoft includes the Online analytical processing (OLAP) and Data Mining as standard features in SQL Server 2000 Enterprise Edition. So, you can save up to four times with SQL Server 2000 Enterprise Edition if you use OLAP and Data Mining. The price comparisons below were based on the Oracle and SQL Server 2000 Price Comparison article from Microsoft. Compare pricing for SQL Server 2000 Standard Edition and Oracle9i Standard Edition: Number of CPUs Oracle9i Standard Edition SQL Server 2000 Standard Edition 1 $15,000 $4,999 2 $30,000 $9,998 4 $60,000 $19,996 8 $120,000 $39,992 16 $240,000 $79,984 32 $480,000 $159,968 Features comparison Both SQL Server 2000 and Oracle 9i Database support the ANSI SQL-92 entry level and do not support the ANSI SQL-92 intermediate level. In the Features comparison section of this article I want to make the brief comparison of the Transact-SQL with PL/SQL and show some SQL Server 2000 and Oracle 9i Database limits. Conclusion It is not true that SQL Server 2000 is better than Oracle 9i or vice versa. Both products can be used to build stable and efficient system and the stability and effectiveness of your applications and databases depend rather from the experience of the database developers and database administrator than from the database's provider. But SQL Server 2000 has some advantages in comparison with Oracle 9i and vice versa. The SQL Server 2000 advantages: ? SQL Server 2000 is cheaper to buy than Oracle 9i Database. ? SQL Server 2000 holds the top TPC-C performance and price/performance results. ? SQL Server 2000 is generally accepted as easier to install, use and manage. The Oracle 9i Database advantages: ? Oracle 9i Database supports all known platforms, not only the Windows-based platforms. ? PL/SQL is more powerful language than T-SQL. ? More fine-tuning to the configuration can be done via start- up parameters.

-- Veena (wenarv@yahoo.com), August 11, 2004.

tell me difference between oracle 8i and sql server 2000 -- ranjan (ranjan_kuku@yahoo.com), August 12, 2004.

Bristle Software SQL Tips
This page is offered as a service of Bristle Software, Inc. New tips are sent to an associated mailing list when they are posted here. Please send comments, corrections, any tips you'd like to contribute, or requests to be added to the mailing list, to tips@bristle.com.

Table of Contents:
1. Oracle Tips 1. SQL Tips 1. SELECT * and more 2. Materialized View 3. Search Source Code of Stored Procedures 2. PL/SQL Tips 3. SQL Navigator Tips 4. See Also 2. MS SQL Server Tips 1. SQL Tips 1. Dynamic SQL in a Stored Procedure 2. Search Source Code of Stored Procedures 2. SQL Enterprise Manager Tips 1. Keyboard Shortcuts 2. SQL Generating SQL 3. See Also 3. Differences Between Oracle and MS SQL Server 1. Concepts and Terminology 2. Data Types 3. Limits 4. Operators 5. Built-In Functions 6. Differences in SQL Syntax 7. Differences in SQL Semantics 8. Differences in Managing Databases 9. Differences in Managing Database Objects 10. Differences in Managing Users 11. Differences in Integration with MS ADO, RDO, etc.

12. Miscellaneous Differences 13. See Also

Details of Tips:
1. Oracle Tips 1. SQL Tips
This section contains tips on standard SQL (Structured Query Language) statements in Oracle.

1. SELECT * and more
Last Updated: 6/6/1999 Applies to: Oracle 7.3, 8 (and probably earlier versions) To select all columns of a table:
select * from table

However, to select all real columns, plus a pseudocolumn like "user":
select table.*, user from table

The following does not work:
select *, user from table

--Fred

2. Materialized View
Last Updated: 1/7/2002 Applies to: Oracle 8+ Oracle 8i introduced a new feature called a "materialized view". You define it just like any other view, except that you add the keyword MATERIALIZED:
CREATE MATERIALIZED VIEW view_name

A materialized view is like a combination of a table and a view. Like a view, it is defined as a logical view into the data of one or more tables. When you update the tables, subsequent queries of the

view see the updated data. However, like a table, its data is stored in the database. Also, like a table, it is faster if you define indexes for it. A regular view is stored as a mapping of data from tables. When you modify the data in the tables, the view is completely ignored. When you access the view, it joins the data currently in the tables, and returns the data you requested. A materialized view is stored as such a mapping along with a copy of the actual data from the tables. When you modify the data in the tables, the view's copy of the data is also updated. When you access the view, the data is drawn directly from the copy. Thus a materialized view makes table updates a little slower, but makes view queries much faster. It also consumes additional space in the database. You could accomplish the same effect by defining an additional table instead of the view, and using triggers on the component tables to update it each time they are changed. However, using a materialized view is more convenient, more efficient, and clearer to the next person who has to maintain your database. Thanks to Andy Glick for sending me a sample of a materialized view from his application! --Fred

3. Search Source Code of Stored Procedures
Original Version: 1/7/2006 Last Updated: 1/20/2006 Applies to: Oracle 7.3+ Since the source code of all Oracle stored procedures, functions, and packages is stored as data in the database, you can do queries against it like any other data. For example, you can find all references to a given table in all stored procedures, functions, and packages with the following query:
SELECT *

FROM WHERE

all_source LOWER(text) LIKE '%table_name%'

If you don't have SELECT access to the all_source table, you can try user_source or dba_source instead. Thanks to Chris Boos, the most knowledgeable Oracle guru I know, for this and many other tips! Tip within a tip: To prevent the LIKE clause from treating underscore as a wildcard, use the ESCAPE clause, as:
SELECT * FROM all_source WHERE LOWER(text) LIKE '%table\_name%' ESCAPE

'\'

--Fred

2. PL/SQL Tips
This section contains tips on PL/SQL statements -- the Oracle "procedural language" superset of SQL that you use to write stored procedures.

3. SQL Navigator Tips
This section contains tips on the SQL Navigator tool by Quest Systems. It is a graphical front end to the Oracle database, allowing you to create, delete, view, and modify all Oracle objects: tables, views, stored procedures, etc.

4. See Also
Last Updated: 6/6/1999 Applies to: Oracle 7.3+ The following are good sources of info about Oracle: 1. Koch, George, and Kevin Loney. Oracle 8, The Complete Reference. Berkeley CA: For Oracle Press by Osborne McGraw-Hill, 1997. ISBN 0-07882396-X. This book includes introductory database concepts as well as a complete reference to Oracle SQL and PL/SQL statements. The companion CD contains

a complete copy of the book, so you can read it on-line, search it, etc. 2. Any of the O'Reilly books. I've been very impressed by all of the O'Reilly books since my early Unix and X-Windows days in the 80's, and they have a complete series on Oracle, covering PL/SQL, the standard packages, etc. --Fred

2. MS SQL Server Tips 1. SQL Tips
This section contains tips on SQL (Structured Query Language) statements in MS SQL Server.

1. Dynamic SQL in a Stored Procedure
Original Version: 2/7/1999 Last Updated: 3/18/2006 Applies to: MS SQL Server 6.5+ A typical tradeoff for a database application is dynamic SQL (SQL commands embedded in the application -- for flexibility) vs. stored procedures (pre-compiled SQL procedures stored in the database and invoked by name from the application -- for speed and control over what SQL statements get executed). However, you can have the best of both worlds by using dynamic SQL inside your stored procedures. In a stored procedure, you can use the EXEC statement to execute a string of SQL statements that you built dynamically in the stored procedure or read from the database or any other data source. Warnings: 1. Beware of security issues. One advantage of stored procedures is that they hide the underlying table structure, allowing you to grant access to the stored procedure and not to the tables. The stored procedure can access the tables using its own credentials. However, if the stored procedure uses dynamic SQL, the caller of the procedure

will need permissions (select, update, delete, insert) on the tables. 2. Beware of runtime errors, like exceeding the max string length when dynamically building a string of SQL to be executed. 3. Beware of performance issues. For dynamic SQL, the query plan is only created at runtime, and may not even be cached if the dynamic query changes too much. 4. Beware of debugging issues. Dynamic SQL is much harder to debug because you don't know for sure what string value is being passed to EXEC, unless you check it with the SQL Profiler. Thanks to: Steve Rhoads for this tip. Darin Strait for the warnings. --Fred

2. Search Source Code of Stored Procedures
Last Updated: 1/10/2006 Applies to: MS SQL Server 2000+ Since the code of all MS SQL Server stored procedures is stored as data in the database, you can do queries against it like any other data. For example, you can find all references to a given table in all stored procedures in the current database with the following query:
SELECT * FROM syscomments c, sysobjects o WHERE o.id = c.id AND c.text LIKE '%table_name%'

Thanks to Steve Weitzman for this tip! --Fred

2. SQL Enterprise Manager Tips
This section contains tips on the SQL Enterprise Manager tool. It is a graphical front end to the database, allowing you to create, delete, view, and

modify all MS SQL Server objects: tables, views, stored procedures, etc.

1. Keyboard Shortcuts
Original Version: 6/20/1999 Last Updated: 2/20/2006 Applies to: MS SQL Server 7.0+ Here is a list of some of the more useful shortcut keys in SQL Enterprise Manager. Key F1 F4 Ctrl-E Ctrl-R Function Help on SQL Enterprise Manager Search for objects by name, type, etc. Execute selected text in Query Analyzer Hide/show results pane in Query Analyzer

Shift-F1 Help on syntax of current SQL statement

CtrlComment the currently selected text in Query Shift-C Analyzer CtrlUncomment Shift-R CtrlShow the estimated query plan for the Shift-L currently selected text. Ctrl-K Hide/show "Show execution plan, as executed". (The query has to be run for the query plan to be returned to Query Analyzer.)

Obviously, this list is far from complete. Please feel free to mail me your favorite shortcuts. I'll add to this list as time permits. Contributors so far include: Darin Strait For a comprehensive list of shortcuts, search for "shortcut keys" in the SQL Server Books Online. See also: Windows Shortcut Keys --Fred

2. SQL Generating SQL
Last Updated: 2/7/1999 Applies to: MS SQL Server 6.5+

To automate tedious database maintenance chores, you can use SQL statements to generate SQL statements that do your maintenance for you. For example, to change the permissions on all stored procedures in a database, you can use a SELECT statement like:
SELECT 'GRANT EXECUTE ON ' + name + ' TO PUBLIC GO' FROM sysobjects WHERE type = 'P'

The output of this SELECT statement is a series of alternating GRANT and GO statements, one pair per stored procedures, for all stored procedures in the database. Then you copy that output as your next set of commands and execute it. Note: Be sure to leave the line break before the word GO. It is required to start on a new line, after the GRANT statement. Thanks to Steve Rhoads for this tip. --Fred

3. See Also
Original Version: 6/6/1999 Last Updated: 2/20/2006 Applies to: MS SQL Server 6.5+ The following are good sources of info about MS SQL Server: 1. MS SQL Server books on the MSDN Library CD. 2. MS SQL Server Books Online, installed with the client and server tools. Thanks to Darin Strait for mentioning the Books Online. --Fred

Differences Between Oracle and MS SQL Server 1. Concepts and Terminology

Original Version: 6/6/1999 Last Updated: 2/20/2006 Applies to: Oracle 7.3+, MS SQL Server 6.5+ The following table shows some differences in concepts and terminology between Oracle and MS SQL Server: Concept/Ter m Database engine (collection of databases) Database (collection of tables) MS SQL Server MS SQL Server 7+ 6.5 Databas Instance e server

Oracle

Database

Schema

Database Groups Roles Member of appropriate server or database role Also: sa (deprecated) dbo Member of db_owner role

Roles/Groups Roles Database administrator dba account Database owner dba

sa

Databas e Catalog Data - one per Data about Dictionary database INFORMATION_SCHE the database - one per MA views "Master" server database - one per server Blocks and extents Tablespaces Network software Data stream protocol Blocks and Pages and extents extents Not Tablespace supporte File Groups s d SQL*Net Net-library

Transparen Tabular Data Stream (TDS) t Network

Substrate (TNS) Case sensitivity of Depends on character sort Casenames of order, default is caseinsensitive tables, insensitive columns, etc. Synonyms Readonly transaction Supported Not supported Supported Not supported

Thanks to Darin Strait for the MS SQL Server 7+ info. --Fred

2. Data Types
Last Updated: 6/6/1999 Applies to: Oracle 7.3+, MS SQL Server 6.5+ The following table shows the corresponding data types in Oracle and MS SQL Server: Data Type Fixed Length String Oracle CHAR(n) - limit 2KB VARCHAR2(n), VARCHAR(n) - limit 4KB in a column - limit 32KB in a variable - VARCHAR is obsolete INTEGER, INTEGER(n), SMALLINT MS SQL Server CHAR(n), CHARACTER(n) - limit 255 (6.5) - limit 8KB (7.0) VARCHAR(n), CHAR VARYING(n), CHARACTER VARYING(n) - limit 255 (6.5) - limit 8KB (7.0) INTEGER (4 bytes), INT (4 bytes), SMALLINT (2 bytes), TINYINT (1 byte), BIT (1 bit)

Variable Length String

Integer

Fixed Point NUMBER, NUMERIC, NUMERIC(n), NUMBER(n), NUMERIC(n,d), NUMBER(n,d), DECIMAL, DECIMAL(n), FLOAT, FLOAT(n), DECIMAL(n,d),

FLOAT(n,d) Floating Point DECIMAL

DEC, DEC(n), DEC(n,d), MONEY, SMALLMONEY FLOAT, FLOAT(n), DOUBLE PRECISION, REAL, DATETIME, SMALLDATETIME, TIMESTAMP - TIMESTAMP autoupdated

Date

DATE

Binary

BINARY(n), VARBINARY(n), BINARY RAW(n) VARYING(n) - limit 255 bytes - limit 255 (6.5) - limit 8KB (7.0) LONG, LONG VARCHAR - limit 2GB - limit one per table row CLOB - limit 4GB LONG RAW - limit 2GB - limit one per table row BLOB - limit 4GB

Large String

TEXT - limit 2GB

Large Binary

IMAGE - limit 2GB

NCHAR(n), NATIONAL CHAR(n), NATIONAL NCHAR(n) CHARACTER(n) NVARCHAR(n) NVARCHAR(n), NATIONAL Multi-byte NCLOB CHAR VARYING(n), chars - same limits as NATIONAL CHARACTER CHAR, VARCHAR, VARYING(n) CLOB NTEXT, NATIONAL TEXT - same limits as CHAR, VARCHAR, TEXT OS File Row Identifier BFILE implicit ROWID column <not supported> (use an IDENTITY column)

Secure OS MLSLABEL, RAW <not supported> Label MLSLABEL 128-bit <not supported> UNIQUEIDENTIFIER

Unique Number (UUID, GUID) --Fred

(version 7.0 only)

3. Limits
Original Version: 6/7/1999 Last Updated: 2/20/2006 Applies to: Oracle 7.3+, MS SQL Server 6.5+ The following table shows differences in limits of Oracle and MS SQL Server: MS SQL MS SQL Server Server 7+ 6.5 250 1024 8060 bytes - Includes pointers, but not data, for TEXT and IMAGE columns - With 2000, some text can be stored in-row

Description Columns per table

Oracle 1000

Row size

Unlimited

1962 bytes

LONG and LONG 1 (must be Unlimited (16-byte pointer RAW columns last per) per row column) LOB, TEXT, and Unlimited (16-byte pointer per) IMAGE columns per row Clustered indexes per table Non-clustered indexes per table Columns per index 1

unlimited 16

249

Index row size Tables per SELECT Source code per stored procedure

2K bytes

900 bytes 128 chars 16 64KB 256 250MB

Identifier Length 30 chars unlimited

Data type limits (see Data Types) For more info, search for "capacity" in the SQL Server Books Online. Thanks to Darin Strait for updating the MS SQL Server 7+ info. --Fred

4. Operators
Last Updated: 6/7/1999 Applies to: Oracle 7.3+, MS SQL Server 6.5+ Most operators are the same in Oracle and MS SQL Server. Here are some that differ: Description String concatenation --Fred Oracle string1 || string2 MS SQL Server string1 + string2

5. Built-In Functions
Original Version: 6/7/1999 Last Updated: 2/20/2006 Applies to: Oracle 7.3+, MS SQL Server 6.5+ Oracle and MS SQL Server offer many of the same builtin functions. For example, they both offer ABS, EXP, ROUND, UPPER, LOWER, AVG, COUNT, SUM, ASCII, etc. The following table shows some of the corresponding functions that don't have the same name. For a more complete list, see "Migrating Oracle Applications to SQL Server"

Descriptio n Smallest integer >= CEIL n Modulus Truncate number MOD TRUNC

Oracle

MS SQL Server CEILING % <none> <none> ISNULL

Max or min GREATEST, number or LEAST string in list Translate NULL to n NVL

As of 7.0, also: COALESCE NULLIF

DECODE Return NULL if two values As of Oracle 9i, also: are equal NULLIF String concatenatio CONCAT(str1,str2) n Convert ASCII to char Capitalize first letters of words Find string in string CHR

str1 + str2

CHAR

INITCAP INSTR

<none> CHARINDEX PATINDEX DATALENGTH <none>

Find pattern INSTR in string String length LENGTH

Pad string LPAD, with blanks RPAD

Workaround: Use REPLICATE(' ', n) and string concatenation <none>

Trim leading LTRIM(str,chars), or trailing RTRIM(str,chars) chars other

than blanks Replace chars in string Convert number to string Convert string to number REPLACE STUFF, REPLACE

TO_CHAR

STR, CAST

TO_NUMBER

CAST

Get substring SUBSTR from string Char for char translation in string Date addition TRANSLATE

SUBSTRING

<none>

ADD_MONTH or +

DATEADD or +

Date MONTHS_BETWEEN or DATEDIFF subtraction Last day of LAST_DAY month Time zone conversion Next specified weekday after date Convert date to string Convert string to date Convert date to number Date truncate NEW_TIME <none> <none>

NEXT_DAY

<none>

TO_CHAR

DATENAME, CONVERT CAST

TO_DATE

TO_NUMBER(TO_CHAR( DATEPART d)) CONVERT CONVERT GETDATE or

Date round ROUND TRUNC

Current date SYSDATE

CURRENT_TIMESTA MP Convert hex HEXTORAW to binary Convert binary to hex RAWTOHEX CAST CONVERT

DECODE If statement As of Oracle 9i, also: in an CASE ... WHEN expression or COALESCE User's login id number UID, USER or name User's database id UID, USER number or name Current user USER Thanks to:

CASE ... WHEN or COALESCE SUSER_ID (deprecated), SUSER_NAME (deprecated), SUSER_SNAME (preferred) USER_ID, USER_NAME USER

Jason Deacon for prompting me to update the Oracle column to reflect the new support for ANSI/ISO syntax. Darin Strait for some MS SQL Server info. --Fred

Differences in SQL Syntax
Original Version: 6/7/1999 Last Updated: 3/5/2006 Applies to: Oracle 7.3+, MS SQL Server 6.5+ The following table shows the different syntax used in Oracle and MS SQL Server for the same SQL operations: Descriptio n Oracle MS SQL Server

Left Outer FROM table1 LEFT FROM table1 LEFT Join OUTER JOIN table2 ON OUTER JOIN

(table1.column1 = table2.column2)

Note: The following syntax is also supported, and was the only syntax Note: The prior to version 9i: following syntax is WHERE column1 = also supported, but column2(+) is no longer recommended: All rows from the right WHERE column1 plus nulls to match *= column2 additional rows from the left. FROM table1 RIGHT OUTER JOIN table2 ON FROM table1 ( table1.column1 = RIGHT OUTER table2.column2) JOIN table2 ON table1.column1 = Note: The following table2.column2 syntax is also supported, Right Outer and was the only syntax Note: The Join prior to version 9i: following syntax is also supported, but WHERE column1(+) = is no longer column2 recommended: WHERE column1 All rows from the left plus =* column2 nulls to match additional rows from the right. Full Outer Join SELECT without FROM As of Oracle 9i: FROM table1 FULL FROM table1 FULL OUTER JOIN OUTER JOIN table2 ON table2 ON (table1.column1 = table1.column1 = table2.column2) table2.column2 SELECT 'hello world' FROM DUAL SELECT 'hello world' SELECT ... INTO SELECT ... WHERE EXISTS (SELECT ...) SELECT ... WHERE

table2 ON table1.column1 = table2.column2

SELECT CREATE TABLE AS data into a SELECT ... table Intersectio SELECT ... INTERSECT n of 2 SELECT ... SELECTS Subtraction SELECT ... MINUS

of 2 SELECTS

SELECT ...

NOT EXISTS (SELECT ...)

INSERT Create a VIEW and INSERT INTO SELECT ... into a JOIN INSERT INTO it. UPDATE data in a JOIN UPDATE SELECT... UPDATE table1 t1 SET field1 = (SELECT ... FROM table2 t2 WHERE <condition involving both t1 and t2>) WHERE EXISTS (SELECT ... FROM table2 WHERE <condition involving both t1 and t2>) DELETE FROM table1 t1 WHERE EXISTS (SELECT ... FROM table2 WHERE <condition involving both t1 and t2>) As of Oracle 8i: ALTER TABLE table_name DROP COLUMN column_name CREATE VIEW ... WITH READONLY Create a VIEW and INSERT INTO it.

UPDATE one table based on criteria in another table

UPDATE table FROM ...

DELETE rows from one table based on criteria in another table DROP a column from a table Readonly VIEW

DELETE FROM table FROM ...

ALTER TABLE table_name DROP COLUMN column_name GRANT SELECT ... SAVE TRANSACTION

Save point SAVEPOINT Table lock Exclusive table lock Reserving index space

LOCK TABLE...IN SHARE SELECT...table_na MODE me (TABLOCK) LOCK TABLE...IN EXCLUSIVE MODE PCTFREE=0 SELECT...table_na me (TABLOCKX) FILLFACTOR=100

Declaring a DECLARE varname type; DECLARE local @varname type

variable Initializing DECLARE varname type a local := value; variable DECLARE varname Declaring a CONSTANT type := constant value; Assigning to a variable Assigning to a variable from a cursor varname := value SELECT value INTO varname <not supported>

<not supported> SET @varname = value SELECT @varname = value

FETCH NEXT FROM FETCH cursorname INTO cursorname INTO varname varname DECLARE curname CURSOR FOR SELECT ... IF ... BEGIN ... END ELSE BEGIN ... END WHILE ... BEGIN ... END <not supported> BREAK, CONTINUE

CURSOR curname Declaring a (params) cursor IS SELECT ...; IF ... THEN If ELSIF ... THEN statement ELSE ENDIF While loop Other loops Loop exit Print output Raise error WHILE ... LOOP END LOOP FOR ... END LOOP LOOP ... END LOOP EXIT, EXIT WHEN

DBMS_OUTPUT.PUT_LINE PRINT RAISE_APPLICATION_ER RAISERROR ROR None required, but semi-colons are tolerated as of 2000. GO is used to terminate a batch of statements.

Statement Semi-colon (;) terminator

INSERT As of SQL Server As of Oracle 9i: with some 2000 (perhaps 7): columns getting INSERT INTO table1 VALUES (123, their DEFAULT, 'a string', NULL) default values UPDATE resetting some columns back to their default values Thanks to: Tom Johnston for catching a mistake in this tip. I had the FROM DUAL in the wrong column. Jason Deacon for prompting me to update the Oracle column to reflect the new support for ANSI/ISO syntax. Darin Strait for some MS SQL Server info. Tom Luskin for the technique of updating one table from another in Oracle via 2 correlated subqueries. --Fred As of Oracle 9i: As of SQL Server 2000 (perhaps 7):

UPDATE table1 SET col1 = 123, col2 = DEFAULT, col3 = 'a string', col4 = NULL

Differences in SQL Semantics
Original Version: 6/6/1999 Last Updated: 2/20/2006 Applies to: Oracle 7.3+, MS SQL Server 6.5+ The following table shows some semantic differences between Oracle and MS SQL Server: Description Commit Oracle Explicit COMMIT statement required MS SQL Server Automatic commit unless SET IMPLICIT_TRANSACTIONS ON Depending on options, reader is allowed to read

Reading Database uncommitted does

data

temporary internal rollback to reconstruct most recently committed data for reader. CLOSE CURSOR releases all data. You can't reopen.

uncommitted data, or is forced to wait for writer to commit or rollback. As of 2005: New functionality designed to mimic Oracle's writersdon't-block-readers consistency model. CLOSE CURSOR does not release data. You must explicitly call DEALLOCATE CURSOR. Until then, you can re-open the cursor.

Releasing cursor data

Implicit data conversion in a statement like the following where vc is a column of type VARCHAR2:

As each row The number 123 is is fetched converted to the string '123' from the once, and then the data is table, an fetched from the table. If attempt is any row contains a value made to that cannot be converted to convert it to a number, it simply doesn't a number match '123' and is skipped for the without any error. comparison SELECT * with 123. If Use the ISNUMERIC() FROM person any row function for more control, to WHERE vc contains a search for expressions that =123 do (or do not) evaluate to a value that valid numeric types. cannot be converted to a number, a runtime error occurs. Conversion to Setting a NULL VARCHAR2 column to '' (the empty string) makes it NULL. Setting a VARCHAR column to '' makes it the empty string (not NULL). Note: With text columns, this usually means that an 8KB page is allocated to store the empty string. Setting the column to NULL releases that storage. Typically, cursors are slower than joined select, insert,

Cursor performance

update or delete operations. Thanks to Darin Strait for some MS SQL Server info. --Fred

Differences in Managing Databases
Last Updated: 6/6/1999 Applies to: Oracle 7.3+, MS SQL Server 6.5+ The following table shows some differences in how databases are managed in Oracle and MS SQL Server: Description Model database Oracle No model database MS SQL Server Newly created databases inherit characteristics (users, etc.) from the special database named "model".

--Fred

Differences in Managing Database Objects
Original Version: 6/6/1999 Last Updated: 3/18/2006 Applies to: Oracle 7.3+, MS SQL Server 6.5+ The following table shows some differences in how database objects (tables, views, stored procedures, etc.) are managed in Oracle and MS SQL Server: Descriptio n Fully qualified name Temp tables Oracle MS SQL Server

[schema.]ta [[[server.][database].][owner].] ble table [schema.]vie [[[server.][database].][owner].] w view Pre 8i: Temporary tables must be deleted explicitly #table -- Any table named starting with a pound sign (#) is automatically dropped when the user logs off or the procedure ends. ##table -- Same as above,

8i+: CREATE GLOBAL TEMPORAR Y TABLE

except that the table is accessible to other users and is dropped when the last user who referenced it logs off.

You have to choose which action ReCREATE OR to take. If it doesn't already creating an REPLACE ... exist, use: object that (Oracle CREATE ... may or chooses If is does exist, use: may not correctly ALTER ... already which action or the sequence: exist to take.) DROP ... CREATE ... Create view CREATE before FORCE dependent VIEW tables Not supported. Tables used by view must exist before view can be created.

Thanks to Darin Strait for some clarifications. --Fred

Differences in Managing Users
Original Version: 6/6/1999 Last Updated: 2/20/2006 Applies to: Oracle 7.3+, MS SQL Server 6.5+ The following table shows some differences in how users are managed in Oracle and MS SQL Server: Description Oracle Each user can be a member of any number of groups. MS SQL Server 6.5 Each user can be a member of only one group other than "public". MS SQL Server 7+ Each user can be a member of any number of roles.

Membership in groups

Thanks to Darin Strait for the MS SQL Server 7+ info. --Fred

Differences in Integration with MS ADO, RDO, etc.
Original Version: 6/7/1999 Last Updated: 1/14/2006 Applies to: Oracle 7.3+, MS SQL Server 6.5+ The following table shows the different techniques used in Oracle and MS SQL Server to interact with MS ADO, RDO, etc.: Description Oracle Return a handle to a cursor. For more info: See MS KB article Q174679. Can return multiple recordsets as multiple output parameters. MS SQL Server SELECT with no INTO clause; Multiple such SELECTs return multiple recordsets

Return a recordset to the caller

--Fred

Miscellaneous Differences
Original Version: 6/6/1999 Last Updated: 2/20/2006 Applies to: Oracle 7.3+, MS SQL Server 6.5+ The following table shows miscellaneous differences between Oracle and MS SQL Server: MS SQL Server 6.5 MS SQL Server 7+

Description Generate unique numbers Cascaded DELETE

Oracle

CREATE IDENTITY column of a SEQUENCE table DELETE CASCADE ... (use triggers) DELETE CASCADE ...

Call a user-defined Supported function from a SQL statement (as column of SELECT or expression in

Not Supported supported

WHERE clause) Thanks to Darin Strait for the MS SQL Server 7+ info. --Fred

See Also
Original Version: 6/7/1999 Last Updated: 3/3/2001 Applies to: Oracle 7.3+, MS SQL Server 6.5+ The following are good sources of info about differences between Oracle and MS SQL Server: 1. Bowman, Judith S., Sandra L. Emerson, and Marcy Darnovsky. The Practical SQL Handbook. AddisonWesley Publishing Company, 1993. ISBN 0-20162623-3. This book gives a good introduction to SQL, with a slight emphasis on Sybase, but with a useful summary in the back of the syntax for each of the SQL statements (SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, GRANT, REVOKE, etc.) for each of the major databases (Oracle, Sybase, DB2, Informix, Ingres, etc.) The book pre-dates MS SQL Server, but the Sybase info is a good approximation since MS SQL Server is a derivative of Sybase. 2. "Migrating Oracle Applications to SQL Server" on MSDN CD, and at MS TechNet Web site: http://www.microsoft.com/resources/documentati on/sql/2000/all/reskit/en-us/part2/c0761.mspx Microsoft clearly intended this to be used in one direction only, but I've used it quite successfully to translate my SQL Server knowledge to Oracle as well. --Fred
©Copyright 1999-2006, Bristle Software, Inc. All rights reserved Migrating from Oracle to SQL Server In Microsoft public newsgroups, I've been observing a recent increase in the number of questions that deal with migrating from Oracle to SQL Server. It is not an easy task to migrate your Oracle database and applications to SQL Server, as there are major architectural differences between SQL Server and Oracle. Further,

Oracle's PL/SQL is vastly different from Microsoft's Transact-SQL (T-SQL). The most commonly asked question is, "Is there a tool that I can use, to translate my PL/SQL scripts, stored procedures, triggers and functions into T-SQL?" Sadly, the answer is No. There is no magic tool that can convert all your PL/SQL code to T-SQL. Even if such a tool exists, I can guarantee that it will not work in all situations. So, migrating or porting your PL/SQL code to T-SQL is a painfully manual process. The more standard (ANSI SQL) SQL you write, the more easier it is to translate, as ANSI SQL is more likely to work independant of the RDBMS. However, it need not be that manual anymore. I recently learned about a tool from DBBest.com. Do check it out! Also, do not forget to check out SwisSQL Database Migration tools. If you are tasked with porting or migrating an Oracle database application to Microsoft SQL Server, the following are the primary resources you should approach for help and migration guidelines: White Paper: Migrating Oracle Databases to SQL Server 2000 Read chapter 7 (Migrating Oracle Databases to SQL Server 2000) from this very useful book: Microsoft SQL Server 2000 Resource Kit Click here to read my review of this book Click here to buy this book from: Amazon.com or Amazon.co.uk or Amazon.ca

At the end of this article, I will provide you with more links to books, that are useful for Oracle DBAs and developers, entering the Microsoft SQL Server world. The following table addresses the most frequently asked questions (FAQ), related to migrating from Oracle to SQL Server. This is list is by no means complete and will be updated periodically. Oracle %TYPE data type SQL Server No equivalent More Information The %TYPE data type of Oracle, lets you create a variable and have that variable's data type be defined by a table or view column or a PL/SQL package variable. There is no equivalent for Oracle's %TYPE datatype in T-SQL, but it can be simulated (not very conveniently though) using User Defined Data types (UDT). Here is an example: EXEC sp_addtype 'MyType', 'smallint', NULL CREATE TABLE MyTable (i MyType)

CREATE PROC MyProc AS BEGIN DECLARE @i MyType END BEFORE triggers INSTEAD OF Use INSTEAD OF trigger in SQL Server as an triggers equivalent to Oracle's BEFORE trigger. For more information on INSTEAD OF triggers, see SQL Server Books Online DECODE() function CASE expression DECODE can be conveniently simulated using the T-SQL CASE expression. Here's an example: SELECT Sport, CASE Sport WHEN 'Cricket' THEN 'England' WHEN 'Hockey' THEN 'India' WHEN 'Base Ball' THEN 'America' ELSE NULL END AS 'Originating Country' FROM Sports DESCRIBE sp_help or sp_columns There are a lot of alternatives for Oracle's DESCRIBE, in SQL Server. You could use the system stored procedure sp_help for detailed information about a table's columns and other properties. If sp_help is providing you with too much information, then try the ODBC catalog stored procedure, sp_columns. There are a bunch of other useful sp_help* stored procedures available in SQL Server. You can find more information about those in SQL Server Books Online. If none of those procedures are suitable for your requirements, then you could query the system view INFORMATION_SCHEMA.COLUMNS, to get the desired information. You could wrap your code inside a stored procedure named DESCRIBE, if you wish. As a last resort, you could even query system tables like sysobjects and syscolumns, but this is not a recommended approach. DUAL table No equivalent There is no DUAL table in SQL Server. In fact, you don't need one in SQL Server, as you can have a SELECT statement without a FROM clause.

For example, consider the following SELECT statement in Oracle: SELECT 'Something' FROM DUAL In SQL Server, the same result can be obtained by the following command: SELECT 'Something' If you are porting some code from Oracle into SQL Server and if you don't want to remove all references to DUAL table, then just create a DUAL table in your database using the following commands: CREATE TABLE DUAL ( DUMMY varchar(1) ) INSERT INTO DUAL (DUMMY) VALUES ('X') INTERSECT operator Not supported Use EXISTS clause to generate the same result. The following example illustrates the simulation of Oracle's INTERSECT operator: SELECT OrderID, OrderDate FROM Orders O WHERE EXISTS ( SELECT 1 FROM RefundsTable R WHERE O.OrderID = R.OrderID ) MINUS operator Not supported Use NOT EXISTS clause in your SELECT statement to generate the same result. The following example illustrates the simulation of Oracle's MINUS operator: SELECT OrderID, OrderDate FROM Orders O WHERE NOT EXISTS ( SELECT 1 FROM RefundsTable R WHERE O.OrderID = R.OrderID ) Nested tables Not supported Oracle 8i and prior versions didn't support this feature and is introduced in Oracle 9i.

This feature basically enables you to store a table, within a column. It is like having an array of records in your database columns. SQL Server has no concept of nested tables. As a workaround, You could store your subtables or child tables in the form of XML inside a char, nchar, varchar, nvarchar, text or ntext type column, and parse it as needed, at runtime. See OPENXML, sp_xml_preparedocument, sp_xml_removedocument in SQL Server 2000 Books Online. Another possible workaround would be to store comma separated values (CSV). Note that this is against the basic rules of normalization. Columns are nomore atomic, with nested tables. From a design point of view, best thing to do would be, to create different tables for representing different entities and link them with primary and foreign key relationships. This will also make searching easier. Oracle Packages PL/SQL SQL Server Not supported T-SQL :-) No equivalent in SQL Server for Oracle's Packages and Package variables concept Every database product implements and extends the standard SQL. Oracle's implementation of SQL is called PL/SQL, while Microsoft's is called T-SQL (Transact-SQL) Though there is no inbuilt support in SQL Server for row level permissions, you can implement it using view and system functions. For more information and a working example, read this article: Implementing row level permissions/security in SQL Server databases rownum pseudo column No equivalent Though there is no rownum or rowid in SQL Server, there are several ways in which a row number can be generated. For some examples, read this article: Q186133 INF: How to Dynamically Number Rows in a Select Statement

Row level security

No equivalent

SELECT...FOR UPDATE

UPDLOCK hint

Use the locking hint UPDLOCK in your SELECT statement. See SQL Server Books Online for more information.

Sequences

IDENTITY

It is much simpler in SQL Server to generate a sequence value for a primary key or a nonkey column. You just need to turn on the IDENTITY property of column. IDENTITY property can be set to columns of the following data types: tinyint, smallint, int, bigint, decimal, numeric Try this example to see how it works: CREATE TABLE foo ( i int IDENTITY(1, 1) j int ) INSERT INTO foo (j) VALUES (911) INSERT INTO foo (j) VALUES (999)

SQL *Plus

Query Analyzer

For connecting to SQL Server and executing queries and modifying data, use the built-in Query Analyzer. It is much more powerful and friendlier than Oracle's SQL *Plus Though there's no direct equivalent in T-SQL for Oracle's START WITH...CONNECT BY, there are several ways and efficient techniques for processing and querying hierarcical data. For more information, read this article: Working with hierarchical data in SQL Server databases

START WITH...CONNECT BY clause

No equivalent

Synonym

Views

You can simulate Oracle Synonyms in SQL Server using Views. For example, the following creates a view that returns the OrderID and OrderDate from Orders table. CREATE VIEW vOrders AS SELECT OrderID, OrderDate FROM Orders Now you can select data from the view, using

the following SELECT statement: SELECT * FROM vOrders The following example will create a view which is equivalent to Oracles TABS synonym or USER_TABLES data dictionary view (For simplicity, I am only including the table name in the view definition): CREATE VIEW TABS AS SELECT name AS table_name FROM sysobjects WHERE type = 'U' Now you can execute the following SELECT statement to return all user table names: SELECT table_name FROM TABS