Application development using Microsoft SQL Server 2000 Peter Ty Developer Evangelist .NET and Developer Group
SQL Server 2000  <ul><li>Application Migration  </li></ul><ul><li>Engine Enhancement </li></ul><ul><li>XML Support </li></...
Application Migration <ul><li>Avoid accessing System Tables </li></ul><ul><li>SQL-SCM API removed </li></ul><ul><li>SQL6.5...
<ul><li>Automatic Cascading of Deletes and Updates from PK to FK Tables </li></ul><ul><li>ANSI Standard Restrict and Casca...
Engine Enhancements   User-Defined Functions <ul><li>Multi-Statement T-SQL Routines </li></ul><ul><li>Scalar-Valued </li><...
Engine Enhancements  Scalar UDF Example <ul><li>CREATE FUNCTION ExtractNamePart(@InName varchar(100), @part tinyint) </li>...
Engine Enhancements  Column-Level Collations <ul><li>Multilingual Applications, Application Hosting, and Server Consolidat...
Engine Enhancements  Instead-Of Triggers <ul><li>Trigger Executed Instead of INSERT, DELETE, or UPDATE Operation </li></ul...
Engine Enhancements  Instead-Of Trigger Example <ul><li>Updateable Partitioned View </li></ul><ul><ul><li>Partitioning col...
Engine Enhancements  Instead-Of Trigger Example <ul><li>CREATE TRIGGER IO_Trig_INS_CustomersAll ON CustomersAll </li></ul>...
Engine Enhancements  New Data Types <ul><li>Table </li></ul><ul><ul><li>Return type for table-valued UDFs </li></ul></ul><...
Engine Enhancements  Indexes on Computed Columns <ul><li>Computed Columns Were Introduced in SQL Server 7.0 </li></ul><ul>...
Engine Enhancements  Indexes on Views <ul><li>Defining an Index on a View </li></ul><ul><ul><li>A.k.a., Materialized views...
Engine Enhancements  Indexes on Views <ul><li>Creating an Index on a View – Considerations </li></ul><ul><ul><li>SET optio...
XML Support XML Query Results <ul><li>SQL Language Extension </li></ul><ul><ul><ul><li>SELECT… </li></ul></ul></ul><ul><ul...
XML Support FOR XML – Raw Mode <ul><li>One <Row> Element Per Row in the Result Set </li></ul><ul><li>No Nested Elements </...
XML Support FOR XML – Auto Mode <ul><li>Table / View Name in the Database Used for the Element Name </li></ul><ul><li>Colu...
XML Support FOR XML – Explicit Mode <ul><li>Provides Complete Control Over Format of XML Result </li></ul><ul><li>Columns ...
XML Support  HTTP Access – URL Types <ul><li>URL Query </li></ul><ul><ul><li>http://server/vroot?sql=“…” </li></ul></ul><u...
XML Support  OpenXML <ul><li>Used with T-SQL Stored Procedures </li></ul><ul><li>Provides a Relational View on XML </li></...
Multiple Instances <ul><li>Default </li></ul><ul><ul><li>Only one active </li></ul></ul><ul><ul><li>Version switch </li></...
Multiple Instances <ul><li>Support multiple SQL server instances on single machine </li></ul><ul><li>Applications: </li></...
More Resources <ul><li>msdn.microsoft.com   </li></ul><ul><li>www.microsoft.com/sql </li></ul><ul><li>msdn.microsoft.com/s...
 
Upcoming SlideShare
Loading in …5
×

Application development using Microsoft SQL Server 2000

436 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
436
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
9
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Application development using Microsoft SQL Server 2000

  1. 1. Application development using Microsoft SQL Server 2000 Peter Ty Developer Evangelist .NET and Developer Group
  2. 2. SQL Server 2000 <ul><li>Application Migration </li></ul><ul><li>Engine Enhancement </li></ul><ul><li>XML Support </li></ul><ul><li>Multiple Instances </li></ul>
  3. 3. Application Migration <ul><li>Avoid accessing System Tables </li></ul><ul><li>SQL-SCM API removed </li></ul><ul><li>SQL6.5: SQL-DMO, Tasks and replication: objects changed </li></ul><ul><li>SQL6.5: DUMP/LOAD: uses BACKUP/RESTORE </li></ul><ul><li>Setting Backward Compatibility level: sp_dbcmptlevel (60, 65, 70, 80) </li></ul><ul><li>Uses ADO/ADO.NET </li></ul>
  4. 4. <ul><li>Automatic Cascading of Deletes and Updates from PK to FK Tables </li></ul><ul><li>ANSI Standard Restrict and Cascade Semantics </li></ul>Engine Enhancements Cascaded DRI <ul><ul><li>CREATE TABLE country ( </li></ul></ul><ul><ul><li>country_name NVARCHAR(75) NOT NULL PRIMARY KEY ) </li></ul></ul><ul><ul><li>CREATE TABLE employee ( </li></ul></ul><ul><ul><li>employee_name NVARCHAR(75) NOT NULL, </li></ul></ul><ul><ul><li>country NVARCHAR(75) NOT NULL REFERENCES country </li></ul></ul><ul><ul><li>ON UPDATE CASCADE </li></ul></ul><ul><ul><li>ON DELETE NO ACTION, </li></ul></ul><ul><ul><li>passport_number VARCHAR(25) NOT NULL, </li></ul></ul><ul><ul><li>PRIMARY KEY (nationality, passport_number)) </li></ul></ul>
  5. 5. Engine Enhancements User-Defined Functions <ul><li>Multi-Statement T-SQL Routines </li></ul><ul><li>Scalar-Valued </li></ul><ul><ul><li>Select f(c1) … </li></ul></ul><ul><ul><li>Select … where f2(c2) </li></ul></ul><ul><ul><li>Usable in any expression (Order By, Group By..) </li></ul></ul><ul><li>Table-Valued (Also Called Relational) </li></ul><ul><ul><li>Select c1 from f(arg)… </li></ul></ul><ul><li>Strongly Typed Input Args with Return Value </li></ul><ul><ul><li>No output parameters </li></ul></ul><ul><li>Inline Relational Functions </li></ul><ul><ul><li>Effectively a parameterized view </li></ul></ul>
  6. 6. Engine Enhancements Scalar UDF Example <ul><li>CREATE FUNCTION ExtractNamePart(@InName varchar(100), @part tinyint) </li></ul><ul><li>RETURNS varchar(30) AS </li></ul><ul><li>BEGIN </li></ul><ul><li>DECLARE @offset tinyint </li></ul><ul><li>SET @offset = charindex(' ', @InName) </li></ul><ul><li>RETURN CASE @part </li></ul><ul><li> WHEN 1 THEN substring(@InName, 1, @offset-1) </li></ul><ul><li> WHEN 2 THEN substring(@InName,@offset+1, len(@InName)) </li></ul><ul><li> ELSE NULL </li></ul><ul><li>END </li></ul><ul><li>END </li></ul>
  7. 7. Engine Enhancements Column-Level Collations <ul><li>Multilingual Applications, Application Hosting, and Server Consolidation </li></ul><ul><li>Per-Database Collations </li></ul><ul><ul><li>Multiple apps with different collations </li></ul></ul><ul><li>Per-Column Collations </li></ul><ul><ul><li>Deeper multi-lingual applications </li></ul></ul><ul><li>Attach and Restore Databases with Different Collations from Server </li></ul><ul><li>Full Backward-Compatibility </li></ul>
  8. 8. Engine Enhancements Instead-Of Triggers <ul><li>Trigger Executed Instead of INSERT, DELETE, or UPDATE Operation </li></ul><ul><li>Application </li></ul><ul><ul><li>Allows any view to be updateable </li></ul></ul><ul><ul><li>Implement before triggers </li></ul></ul><ul><li>Supported on View or Table </li></ul><ul><li>Inserted / Deleted Tables Available </li></ul>
  9. 9. Engine Enhancements Instead-Of Trigger Example <ul><li>Updateable Partitioned View </li></ul><ul><ul><li>Partitioning column: Region </li></ul></ul>CREATE VIEW CustomersAll AS SELECT CustomerID, CompanyName, Address, Region FROM CustomerEast UNION ALL SELECT CustomerID, CompanyName, Address, Region FROM CustomerCentral UNION ALL SELECT CustomerID, CompanyName, Address, Region FROM CustomerWest
  10. 10. Engine Enhancements Instead-Of Trigger Example <ul><li>CREATE TRIGGER IO_Trig_INS_CustomersAll ON CustomersAll </li></ul><ul><li>INSTEAD OF INSERT AS </li></ul><ul><li>BEGIN </li></ul><ul><li>INSERT INTO CustomersEast </li></ul><ul><li>SELECT CustomerID,CompanyName,Address,Region </li></ul><ul><li>FROM inserted WHERE Region = ‘East’ </li></ul><ul><li>INSERT INTO CustomersCentral </li></ul><ul><li>SELECT CustomerID, CompanyName, Address,Region </li></ul><ul><li>FROM inserted WHERE Region = ‘Central’ </li></ul><ul><li>INSERT INTO CustomersWest </li></ul><ul><li>SELECT CustomerID, CompanyName, Address,Region </li></ul><ul><li>FROM inserted WHERE Region = ‘West’ </li></ul><ul><li>END --trigger action </li></ul>
  11. 11. Engine Enhancements New Data Types <ul><li>Table </li></ul><ul><ul><li>Return type for table-valued UDFs </li></ul></ul><ul><ul><li>Allows easier programming of iterative operations </li></ul></ul><ul><li>BigInt </li></ul><ul><ul><li>8-byte integer </li></ul></ul><ul><li>SQL_Variant </li></ul><ul><ul><li>Can store any base type (except LOB) </li></ul></ul><ul><ul><li>Can be used to implement an open schema </li></ul></ul>
  12. 12. Engine Enhancements Indexes on Computed Columns <ul><li>Computed Columns Were Introduced in SQL Server 7.0 </li></ul><ul><li>SQL Server 2000 Allows You to Create Indexes on Computed Columns </li></ul><ul><ul><li>The expression defining the computed column must be DETERMINISTIC </li></ul></ul><ul><ul><li>Certain SET options must be specified </li></ul></ul>
  13. 13. Engine Enhancements Indexes on Views <ul><li>Defining an Index on a View </li></ul><ul><ul><li>A.k.a., Materialized views </li></ul></ul><ul><ul><li>The view may be a join, an aggregation, or their combination </li></ul></ul><ul><ul><li>Once the index is created, the contents of the view are persisted </li></ul></ul><ul><ul><li>The index is maintained automatically, as with any other index </li></ul></ul><ul><ul><li>The optimizer may use the index on a view even if the view is not directly referenced in the query </li></ul></ul>
  14. 14. Engine Enhancements Indexes on Views <ul><li>Creating an Index on a View – Considerations </li></ul><ul><ul><li>SET options consideration and DETERMINISM </li></ul></ul><ul><ul><li>CREATE VIEW with SCHEMABINDING </li></ul></ul><ul><ul><li>CREATE INDEX </li></ul></ul>
  15. 15. XML Support XML Query Results <ul><li>SQL Language Extension </li></ul><ul><ul><ul><li>SELECT… </li></ul></ul></ul><ul><ul><ul><li>FROM… </li></ul></ul></ul><ul><ul><ul><li>WHERE… </li></ul></ul></ul><ul><ul><ul><li>ORDER BY… </li></ul></ul></ul><ul><ul><ul><li>FOR XML (raw | </li></ul></ul></ul><ul><ul><ul><li>auto [, ELEMENTS] | </li></ul></ul></ul><ul><ul><ul><li>explicit) </li></ul></ul></ul><ul><ul><ul><li>[, XMLData] </li></ul></ul></ul><ul><ul><ul><li>[, BINARY base64]) </li></ul></ul></ul>
  16. 16. XML Support FOR XML – Raw Mode <ul><li>One <Row> Element Per Row in the Result Set </li></ul><ul><li>No Nested Elements </li></ul><ul><li>Columns / Values in the Result Set Are Attributes / Values on the <Row> </li></ul><ul><li>Similar to CSV but in XML Format </li></ul>
  17. 17. XML Support FOR XML – Auto Mode <ul><li>Table / View Name in the Database Used for the Element Name </li></ul><ul><li>Column Names Used for Attributes </li></ul><ul><li>Supports Nested XML Output </li></ul><ul><ul><li>Nesting determined by ordering of columns in SELECT clause </li></ul></ul><ul><ul><li>Sibling relationships not supported </li></ul></ul><ul><li>Change Names Using Table and Column Aliases </li></ul>
  18. 18. XML Support FOR XML – Explicit Mode <ul><li>Provides Complete Control Over Format of XML Result </li></ul><ul><li>Columns Can Be Individually Mapped to Attributes or Sub-Elements </li></ul><ul><ul><li>Supports arbitrary nesting </li></ul></ul><ul><ul><li>Sibling relationships supported </li></ul></ul><ul><li>Collapses / Hoists Hierarchy </li></ul><ul><li>Constructs ID/IDREF Relationships </li></ul><ul><li>CDATA Sections in XML Output </li></ul><ul><li>Stores XML Annotations </li></ul>
  19. 19. XML Support HTTP Access – URL Types <ul><li>URL Query </li></ul><ul><ul><li>http://server/vroot?sql=“…” </li></ul></ul><ul><li>Direct Query </li></ul><ul><ul><li>http://server/vroot/dbobject/ xpath </li></ul></ul><ul><li>Template </li></ul><ul><ul><li>http://server/vroot/vname? params </li></ul></ul><ul><li>XML View </li></ul><ul><ul><li>http://server/vroot/vname/ xpath ? params </li></ul></ul>
  20. 20. XML Support OpenXML <ul><li>Used with T-SQL Stored Procedures </li></ul><ul><li>Provides a Relational View on XML </li></ul><ul><li>Specifies Row and Column Selectors Using an XPath </li></ul><ul><li>Supports </li></ul><ul><ul><li>Attribute and element-centric mappings </li></ul></ul><ul><ul><li>XML annotation / overflow column </li></ul></ul><ul><ul><li>Hierarchy support </li></ul></ul>
  21. 21. Multiple Instances <ul><li>Default </li></ul><ul><ul><li>Only one active </li></ul></ul><ul><ul><li>Version switch </li></ul></ul><ul><li>Named </li></ul><ul><ul><li>All instances can be active </li></ul></ul>SQL Server 2000 { { SQL Server 2000 SQL Server 2000 SQL Server 2000 SQL Server 7.0 or 2000 SQL Server 6.5 Up to 15
  22. 22. Multiple Instances <ul><li>Support multiple SQL server instances on single machine </li></ul><ul><li>Applications: </li></ul><ul><ul><li>Application hosting </li></ul></ul><ul><ul><li>Secured Application Isolation </li></ul></ul><ul><ul><li>Development and testing </li></ul></ul><ul><ul><li>Take Full advantage of powerful hardware </li></ul></ul>
  23. 23. More Resources <ul><li>msdn.microsoft.com </li></ul><ul><li>www.microsoft.com/sql </li></ul><ul><li>msdn.microsoft.com/sqlserver </li></ul><ul><li>www.microsoft.com/technet/sql </li></ul><ul><li>msdn.microsoft.com/xml </li></ul>

×