View
230
Download
3
Category
Tags:
Preview:
Citation preview
1
Building Management Applications with SQL Server “Yukon” SQL Management Objects (SMO): Overview
Bruce PrangDevelopment ManagerMicrosoft Corporationbprang@microsoft.com
Session Code: DAT360
2
What is SMOWhat is SMO
SQL Server Management ObjectsProgrammatic object model for DDL operationsUse it for creation, management, discovery, configuration of Sql Servers.NET Class LibraryNot a total abstraction of Sql Server
SQL Server Management ObjectsProgrammatic object model for DDL operationsUse it for creation, management, discovery, configuration of Sql Servers.NET Class LibraryNot a total abstraction of Sql Server
3
Some of the Design GoalsSome of the Design Goals
100% coverage of Sql Server featuresImprove scalability and performanceSimple to use, but rich object modelHigh level of control over object model behaviorAdvanced scripting capabilitiesBuild SQL Server Workbench on it
100% coverage of Sql Server featuresImprove scalability and performanceSimple to use, but rich object modelHigh level of control over object model behaviorAdvanced scripting capabilitiesBuild SQL Server Workbench on it
4
Object ModelObject Model
DatabasesDatabases
ServerServer
ConnectionContextConnectionContext
DatabaseDatabase
SqlAssemblySqlAssembly
FileGroupFileGroup
TablesTables
TableTable
AssembliesAssemblies
FileGroupsFileGroups
JobServerJobServer
JobsJobs
JobJob
AlertsAlerts
AlertsAlerts
Shared SchedulesShared Schedules
Job ScheduleJob Schedule
5
SMO – lets see it
Ovidiu Craciunovidiuc@microsoft.comSql Server Management Tools
6
SMO
SMO ArchitectureSMO Architecture
Utility Utility ClassesClasses
Instance Instance ClassesClasses
Scripter Scripter ClassesClasses
Management ApplicationManagement Application
WMI WMI ProviderProvider
Enumeration Enumeration ComponentComponent
Connection ClassConnection Class (SQL Server .NET Data Provider)(SQL Server .NET Data Provider)
SQL ServerSQL ServerConfigure/EnumConfigure/Enum
7
SMO FeaturesSMO Features
Optimized instantiation of objectsScripting – Basic and AdvancedCapture of Transact-SQLSupport for new Yukon featuresUse of .NET types
E.g. DateTime, Timespan instead of scaled long integers, etc.
Management Object Model for SQL Services and Configuration (through WMI Provider)
Optimized instantiation of objectsScripting – Basic and AdvancedCapture of Transact-SQLSupport for new Yukon featuresUse of .NET types
E.g. DateTime, Timespan instead of scaled long integers, etc.
Management Object Model for SQL Services and Configuration (through WMI Provider)
8
Feature OverviewOptimized InstantiationFeature OverviewOptimized Instantiation
Instance Classes support “optimized (delayed) instantiation”
Object states 1: Partially instantiated (some properties available)2: Fully instantiated
Full instantiation is triggered when a property is called that has not been retrieved yet, or when a method is called that requires a missing property
Instance Classes support “optimized (delayed) instantiation”
Object states 1: Partially instantiated (some properties available)2: Fully instantiated
Full instantiation is triggered when a property is called that has not been retrieved yet, or when a method is called that requires a missing property
9
Feature OverviewOptimized InstantiationFeature OverviewOptimized Instantiation
Can be controlled by programmerDefaultInitFields, PrefetchObjects
Fits any scenario
Can be controlled by programmerDefaultInitFields, PrefetchObjects
Fits any scenario
Memory optimalMemory optimal Network/Query optimalNetwork/Query optimal
Delayed Delayed instantiation instantiation
per object per object [default][default]
Many Many objects objects
fully fully initializedinitialized
10
SMO – lets tune it
Ovidiu Craciunovidiuc@microsoft.comSql Server Management Tools
11
Feature OverviewCapture ModeFeature OverviewCapture Mode
All Transact-SQL generated by performing actions on SMO objects can be captured or recorded
This is NOT transactional, it is only capture
WorkBench Dialogs use this capability to script operations
All Transact-SQL generated by performing actions on SMO objects can be captured or recorded
This is NOT transactional, it is only capture
WorkBench Dialogs use this capability to script operations
12
Feature OverviewScripter ClassFeature OverviewScripter Class
Basic ScriptingAll DMO Scripting options will continue to be supportedScript interface on individual classes will also be available (same as SQL-DMO)
Advanced ScriptingFiltering, available in multiple placesList modificationObject modificationProgress and Error events
Basic ScriptingAll DMO Scripting options will continue to be supportedScript interface on individual classes will also be available (same as SQL-DMO)
Advanced ScriptingFiltering, available in multiple placesList modificationObject modificationProgress and Error events
13
Scripting PhasesScripting Phases
/****** Object: Table [employee] Script Date: 9/28/2001 4:02:31 PM ******/if not exists (select * from dbo.sysobjects where id = object_id(N'[employee]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)BEGINCREATE TABLE [employee](
[emp_id] [empid] COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[fname] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[minit] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS,
[lname] [varchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[job_id] [smallint] NOT NULL CONSTRAINT [DF__employee__job_id__1B0907CE] DEFAULT (1)
Single phase without manipulation
14
Scripting PhasesScripting Phases
ListGeneration
ScriptGeneration
ManipulationDiscovery Manipulation
/****** Object: Table [employee] Script Date: 9/28/2001 4:02:31 PM ******/if not exists (select * from dbo.sysobjects where id = object_id(N'[employee]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)BEGINCREATE TABLE [employee](
[emp_id] [empid] COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[fname] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[minit] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS,
[lname] [varchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[job_id] [smallint] NOT NULL CONSTRAINT [DF__employee__job_id__1B0907CE] DEFAULT (1)
15
How Did We Get Here?How Did We Get Here?
SQL Server 6.x – SQLOLESQL Server 7.0 – SQL-DMOSQL Server 2000 – SQL-DMOSQL Server Yukon– SMO
Architectural limitations in DMONeeded a .Net class libraryNeeded Full Support in object model
SQL Server 6.x – SQLOLESQL Server 7.0 – SQL-DMOSQL Server 2000 – SQL-DMOSQL Server Yukon– SMO
Architectural limitations in DMONeeded a .Net class libraryNeeded Full Support in object model
16
Backwards CompatibleBackwards Compatible
SMO SupportsSQL Server 7.0SQL Server 2000SQL Server “Yukon”COM callable wrappers for Script
DMO “Yukon”Shipping in the Yukon boxWorks against “Yukon”No new Yukon features
SMO SupportsSQL Server 7.0SQL Server 2000SQL Server “Yukon”COM callable wrappers for Script
DMO “Yukon”Shipping in the Yukon boxWorks against “Yukon”No new Yukon features
17
SMO – a little more
Ovidiu Craciunovidiuc@microsoft.comSql Server Management Tools
18
SQL Server ResourcesSQL Server ResourcesWeek long SQL Server “Ask the Experts” lounge in:
Foyer outside Room 309
Support for SQL Server “Yukon” PDC Preview at SQLJunkieshttp://www.sqljunkies.com/forums
SQL Server “Yukon” FAQ Blog at SQLTeamhttp://yukonblog.sqlteam.com/
Other Key Resourceshttp://www.microsoft.com/sql/communityhttp://msdn.microsoft.com/sqlserver/34 world wide user groups,
http://msdn.microsoft.com/usergroups/find.asp
Our most active SQL Server newsgroups,Microsoft.public.sqlserver.programmingMicrosoft.public.sqlserver.serverMicrosoft.public.sqlserver.dtsMicrosoft.public.sqlserver.olapMicrosoft.public.sqlserver.setupMicrosoft.public.sqlserver.replicationMicrosoft.public.sqlserver.msde
Week long SQL Server “Ask the Experts” lounge in: Foyer outside Room 309
Support for SQL Server “Yukon” PDC Preview at SQLJunkieshttp://www.sqljunkies.com/forums
SQL Server “Yukon” FAQ Blog at SQLTeamhttp://yukonblog.sqlteam.com/
Other Key Resourceshttp://www.microsoft.com/sql/communityhttp://msdn.microsoft.com/sqlserver/34 world wide user groups,
http://msdn.microsoft.com/usergroups/find.asp
Our most active SQL Server newsgroups,Microsoft.public.sqlserver.programmingMicrosoft.public.sqlserver.serverMicrosoft.public.sqlserver.dtsMicrosoft.public.sqlserver.olapMicrosoft.public.sqlserver.setupMicrosoft.public.sqlserver.replicationMicrosoft.public.sqlserver.msde
20© 2003-2004 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Recommended