<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Bob Beauchemin's Blog</title>
    <link>http://www.sqlskills.com/blogs/bobb/</link>
    <description>newtelligence powered</description>
    <language>en-us</language>
    <copyright>Bob Beauchemin</copyright>
    <lastBuildDate>Sat, 19 Jul 2008 17:45:23 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.0.7226.0</generator>
    <managingEditor>bobb@sqlskills.com</managingEditor>
    <webMaster>bobb@sqlskills.com</webMaster>
    <item>
      <trackback:ping>http://www.sqlskills.com/blogs/bobb/Trackback.aspx?guid=f0b363e9-2774-43ea-ab21-84d44a346c9a</trackback:ping>
      <pingback:server>http://www.sqlskills.com/blogs/bobb/pingback.aspx</pingback:server>
      <pingback:target>http://www.sqlskills.com/blogs/bobb/PermaLink,guid,f0b363e9-2774-43ea-ab21-84d44a346c9a.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://www.sqlskills.com/blogs/bobb/CommentView,guid,f0b363e9-2774-43ea-ab21-84d44a346c9a.aspx</wfw:comment>
      <wfw:commentRss>http://www.sqlskills.com/blogs/bobb/SyndicationService.asmx/GetEntryCommentsRss?guid=f0b363e9-2774-43ea-ab21-84d44a346c9a</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
When SQL Server creates a CLR appdomain to run code in (a runtime appdomain as noted
in the <a href="http://www.sqlskills.com/blogs/bobb/2008/07/18/DDLAppdomainsAppearInSQLServerLogInSQLServer2008.aspx">previous
blog entry</a>), the appdomain normally stays in place for the lifetime of SQL Server.
This is done to save appdomain create/teardown and assembly load time. Note that DDL
appdomains, as opposed to runtime appdomains, are torn down immediately after they
are used. A friend of mine recently wanted to shutdown an appdomain on purpose
to troubleshoot a problem that he thought might have been SQLCLR-related. So how do
you shutdown a runtime appdomain on purpose?
</p>
        <p>
You could write a .NET proc to call AppDomain.Unload. But I shied away from this for a
few reasons. You'd need to catalog the appdomain as unsafe for the proc to work, which
means marking database as trustworthy or doing the 'signed assembly with key in master'
dance. And I'd really prefer a way to have SQL Server gracefully shutdown the appdomain
itself.
</p>
        <p>
SQL Server will shutdown an appdomain for different reasons. It can shut them down
under extremely low memory conditions or when there is a serious enough unhandled
exceptional condition (e.g. unhandled exceptional condition that could leave .NET
locks in place). We really don't want to cause either of these on purpose just to
shut down an appdomain. Another reason the SQL Server will shut down an appdomain
is when a loaded assembly is altered. You can use the ALTER ASSEMBLY DDL statement
to replace code in place, subject to limitations. When you alter an assembly in place
SQL Server recycles the appdomain to be able to use your new code. Currently executing
code will continue to use the appdomain until the call completes; new requests are
routed to the new appdomain (with the updated code). When all current requests against
the old appdomain complete, the appdomain shuts down. Hmmm, probably not a good idea
to muck with recompiling the producting code either. So...
</p>
        <p>
Compile a simple do-nothing assembly with a simple do-nothing function (say, add two
numbers together). We'll call the assembly 'fred' and the function 'addtwo'. The assembly
must be owned by the same owner as the appdomain you want to recycle (remember runtime
appdomains are on a per database and assembly owner basis). So if the appdomain we
want to recycle is the 'pubs.dbo[runtime]' appdomain...
</p>
        <p>
use pubs<br />
go
</p>
        <p>
create assembly fred authorization dbo ...<br />
create function dbo.addtwo ...<br />
use the function dbo.addtwo (this causes the assembly to be loaded)<br />
recompile the assembly fred<br />
alter assembly fred ... (this cause the eventual appdomain unload) 
</p>
        <p>
Note that you don't have to change the 'fred' assembly, only recompile it. SQL Server
decides that an assembly is changed if it has a different MVID (.NET assembly module
version identifier). New MVIDs are assigned each time an assembly is recompiled (note
that an MVID is not the same as a four-part assembly version number). In Visual Studio,
you'd recompile the assembly by using the Recompile menu entry, not the Build menu
entry. If you try and run alter assembly without a rebuild you'll get the error message
'ALTER ASSEMBLY failed because the source assembly is, according to MVID, identical
to an assembly that is already registered under the name "fred"'. You could conceivably
use Visual Studio autodeploy for these steps as well, but Visual Studio autodeploy
drops the functions and assembly and recreates them rather than using ALTER ASSEMBLY. 
</p>
        <p>
The next request against any of the .NET database objects will cause a new appdomain
to be created.
</p>
        <img width="0" height="0" src="http://www.sqlskills.com/blogs/bobb/aggbug.ashx?id=f0b363e9-2774-43ea-ab21-84d44a346c9a" />
        <br />
        <hr />
This blog is sponsored by <a href="http://www.sqlskills.com">SQLSkills</a>. 
</body>
      <title>How do you shutdown a running SQLCLR appdomain?</title>
      <guid isPermaLink="false">http://www.sqlskills.com/blogs/bobb/PermaLink,guid,f0b363e9-2774-43ea-ab21-84d44a346c9a.aspx</guid>
      <link>http://www.sqlskills.com/blogs/bobb/2008/07/19/HowDoYouShutdownARunningSQLCLRAppdomain.aspx</link>
      <pubDate>Sat, 19 Jul 2008 17:45:23 GMT</pubDate>
      <description>&lt;p&gt;
When SQL Server creates a CLR appdomain to run code in (a runtime appdomain as noted
in the&amp;nbsp;&lt;a href="http://www.sqlskills.com/blogs/bobb/2008/07/18/DDLAppdomainsAppearInSQLServerLogInSQLServer2008.aspx"&gt;previous
blog entry&lt;/a&gt;), the appdomain normally stays in place for the lifetime of SQL Server.
This is done to save appdomain create/teardown and assembly load time. Note that DDL
appdomains, as opposed to runtime appdomains, are torn down immediately after they
are used.&amp;nbsp;A friend of mine recently wanted to shutdown an appdomain on purpose
to troubleshoot a problem that he thought might have been SQLCLR-related. So how do
you shutdown a runtime appdomain on purpose?
&lt;/p&gt;
&lt;p&gt;
You could write a .NET proc to call AppDomain.Unload. But I shied away from this for&amp;nbsp;a
few reasons. You'd need to catalog the appdomain as unsafe for the proc to work, which
means marking database as trustworthy or doing the 'signed assembly with key in master'
dance. And I'd really prefer a way to have SQL Server gracefully shutdown the appdomain
itself.
&lt;/p&gt;
&lt;p&gt;
SQL Server will shutdown an appdomain for different reasons. It can shut them down
under extremely low memory conditions or when there is a serious enough unhandled
exceptional condition (e.g. unhandled exceptional condition that could leave .NET
locks in place). We really don't want to cause either of these on purpose just to
shut down&amp;nbsp;an appdomain. Another reason the SQL Server will shut down an appdomain
is when a loaded assembly is altered. You can use the ALTER ASSEMBLY DDL statement
to replace code in place, subject to limitations. When you alter an assembly in place
SQL Server recycles the appdomain to be able to use your new code. Currently executing
code will continue to use the appdomain until the call completes; new requests are
routed to the new appdomain (with the updated code). When all current requests against
the old appdomain complete, the appdomain shuts down. Hmmm, probably not a good idea
to muck with recompiling the producting code either. So...
&lt;/p&gt;
&lt;p&gt;
Compile a simple do-nothing assembly with a simple do-nothing function (say, add two
numbers together). We'll call the assembly 'fred' and the function 'addtwo'. The assembly
must be owned by the same owner as the appdomain you want to recycle (remember runtime
appdomains are on a per database and assembly owner basis). So if the appdomain we
want to recycle is the 'pubs.dbo[runtime]' appdomain...
&lt;/p&gt;
&lt;p&gt;
use pubs&lt;br&gt;
go
&lt;/p&gt;
&lt;p&gt;
create assembly fred authorization dbo ...&lt;br&gt;
create function dbo.addtwo ...&lt;br&gt;
use the function dbo.addtwo (this causes the assembly to be loaded)&lt;br&gt;
recompile the assembly fred&lt;br&gt;
alter assembly fred ... (this cause the eventual appdomain unload) 
&lt;/p&gt;
&lt;p&gt;
Note that you don't have to change the 'fred' assembly, only recompile it. SQL Server
decides that an assembly is changed if it has a different MVID (.NET assembly module
version identifier). New MVIDs are assigned each time an assembly is recompiled (note
that an MVID is not the same as a four-part assembly version number). In Visual Studio,
you'd recompile the assembly by using the Recompile menu entry, not the Build menu
entry. If you try and run alter assembly without a rebuild you'll get the error message
'ALTER ASSEMBLY failed because the source assembly is, according to MVID, identical
to an assembly that is already registered under the name "fred"'. You could conceivably
use Visual Studio autodeploy for these steps as well, but Visual Studio autodeploy
drops the functions and assembly and recreates them rather than using ALTER ASSEMBLY. 
&lt;/p&gt;
&lt;p&gt;
The next request against any of the .NET database objects will cause a new appdomain
to be created.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.sqlskills.com/blogs/bobb/aggbug.ashx?id=f0b363e9-2774-43ea-ab21-84d44a346c9a" /&gt;
&lt;br /&gt;
&lt;hr /&gt;
This blog is sponsored by &lt;a href="http://www.sqlskills.com"&gt;SQLSkills&lt;/a&gt;. </description>
      <comments>http://www.sqlskills.com/blogs/bobb/CommentView,guid,f0b363e9-2774-43ea-ab21-84d44a346c9a.aspx</comments>
    </item>
    <item>
      <trackback:ping>http://www.sqlskills.com/blogs/bobb/Trackback.aspx?guid=8bf9ad27-ae08-4bf0-8ffd-d528979960e6</trackback:ping>
      <pingback:server>http://www.sqlskills.com/blogs/bobb/pingback.aspx</pingback:server>
      <pingback:target>http://www.sqlskills.com/blogs/bobb/PermaLink,guid,8bf9ad27-ae08-4bf0-8ffd-d528979960e6.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://www.sqlskills.com/blogs/bobb/CommentView,guid,8bf9ad27-ae08-4bf0-8ffd-d528979960e6.aspx</wfw:comment>
      <wfw:commentRss>http://www.sqlskills.com/blogs/bobb/SyndicationService.asmx/GetEntryCommentsRss?guid=8bf9ad27-ae08-4bf0-8ffd-d528979960e6</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
.NET (and therefore SQLCLR) divides up running its code (even within the same process
like the sqlserver.exe process) into appdomains. The appdomain is like a lightweight
process used to enforce isolation between running .NET code within the same Windows
process. SQLCLR (.NET code running in SQL Server) uses appdomains to isolate execution
of .NET code on a per database and per assembly owner basis. 
</p>
        <p>
SQLCLR uses appdomains for two reasons: for running .NET user code like functions
and procedures, and for running DDL to create and alter assemblies. You can see appdomains
being created and destroyed in the SQL Server log, as well as query the current appdomains
by using the sys.dm_clr_appdomains dynamic management view. 
</p>
        <p>
In SQL Server 2005, the SQL Server log only showed user code-running appdomains, the
messages look like this:
</p>
        <p>
AppDomain 4 (testdb.dbo[runtime].3) created.<br />
AppDomain 4 (testdb.dbo[runtime].3) is marked for unload due to common language runtime
(CLR) or security data definition language (DDL) operations.<br />
AppDomain 4 (testdb.dbo[runtime].3) unloaded.
</p>
        <p>
Is these messages there's a appdomain being created for running code in the testdb
database for assemblies owned by dbo. It's a runtime appdomain. The last two messages
show the appdomain (some time later) being unloaded. 
</p>
        <p>
In SQL Server 2005 it was difficult to "see" DDL appdomains, because their presence
was not logged in the SQL Server log. You could deduce they existed by noting that
the AppDomain numbers (e.g. AppDomain 4 above) seemed to contain skips in the number
range. Or if you were extremely lucky, by querying sys.dm_clr_appdomains at *exactly*
the right time.  In SQL Server 2008, it is. You don't see them being created,
but I just executed some DDL to create a SQLCLR assembly and SQL Server log reports:
</p>
        <p>
AppDomain 5 (testdb.dbo[ddl].4) unloaded.
</p>
        <p>
This should make it a little easier to diagnose appdomain-related problems or see
when assemblies have been created or altered.
</p>
        <img width="0" height="0" src="http://www.sqlskills.com/blogs/bobb/aggbug.ashx?id=8bf9ad27-ae08-4bf0-8ffd-d528979960e6" />
        <br />
        <hr />
This blog is sponsored by <a href="http://www.sqlskills.com">SQLSkills</a>. 
</body>
      <title>DDL appdomains appear in SQL Server log in SQL Server 2008</title>
      <guid isPermaLink="false">http://www.sqlskills.com/blogs/bobb/PermaLink,guid,8bf9ad27-ae08-4bf0-8ffd-d528979960e6.aspx</guid>
      <link>http://www.sqlskills.com/blogs/bobb/2008/07/18/DDLAppdomainsAppearInSQLServerLogInSQLServer2008.aspx</link>
      <pubDate>Fri, 18 Jul 2008 23:42:38 GMT</pubDate>
      <description>&lt;p&gt;
.NET (and therefore SQLCLR) divides up running its code (even within the same process
like the sqlserver.exe process) into appdomains. The appdomain is like a lightweight
process used to enforce isolation between running .NET code within the same Windows
process. SQLCLR (.NET code running in SQL Server) uses appdomains to isolate execution
of .NET code on a per database and per assembly owner basis. 
&lt;/p&gt;
&lt;p&gt;
SQLCLR uses appdomains for two reasons: for running .NET user code like functions
and procedures, and for running DDL to create and alter assemblies. You can see appdomains
being created and destroyed in the SQL Server log, as well as query the current appdomains
by using the sys.dm_clr_appdomains dynamic management view. 
&lt;/p&gt;
&lt;p&gt;
In SQL Server 2005, the SQL Server log only showed user code-running appdomains, the
messages look like this:
&lt;/p&gt;
&lt;p&gt;
AppDomain 4 (testdb.dbo[runtime].3) created.&lt;br&gt;
AppDomain 4 (testdb.dbo[runtime].3) is marked for unload due to common language runtime
(CLR) or security data definition language (DDL) operations.&lt;br&gt;
AppDomain 4 (testdb.dbo[runtime].3) unloaded.
&lt;/p&gt;
&lt;p&gt;
Is these messages there's a appdomain being created for running code in the testdb
database for assemblies owned by dbo. It's a runtime appdomain. The last two messages
show the appdomain (some time later) being unloaded. 
&lt;/p&gt;
&lt;p&gt;
In SQL Server 2005 it was difficult to "see" DDL appdomains, because their presence
was not logged in the SQL Server log. You could deduce they existed by noting that
the AppDomain numbers (e.g. AppDomain 4 above) seemed to contain skips in the number
range. Or if you were extremely lucky, by querying sys.dm_clr_appdomains at *exactly*
the right time.&amp;nbsp; In SQL Server 2008, it is. You don't see them being created,
but I just executed some DDL to create a SQLCLR assembly and SQL Server log reports:
&lt;/p&gt;
&lt;p&gt;
AppDomain 5 (testdb.dbo[ddl].4) unloaded.
&lt;/p&gt;
&lt;p&gt;
This should make it a little easier to diagnose appdomain-related problems or see
when assemblies have been created or altered.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.sqlskills.com/blogs/bobb/aggbug.ashx?id=8bf9ad27-ae08-4bf0-8ffd-d528979960e6" /&gt;
&lt;br /&gt;
&lt;hr /&gt;
This blog is sponsored by &lt;a href="http://www.sqlskills.com"&gt;SQLSkills&lt;/a&gt;. </description>
      <comments>http://www.sqlskills.com/blogs/bobb/CommentView,guid,8bf9ad27-ae08-4bf0-8ffd-d528979960e6.aspx</comments>
      <category>SQL Server 2008</category>
    </item>
    <item>
      <trackback:ping>http://www.sqlskills.com/blogs/bobb/Trackback.aspx?guid=1f8edffc-9a0a-41b4-bff4-af01d31364e1</trackback:ping>
      <pingback:server>http://www.sqlskills.com/blogs/bobb/pingback.aspx</pingback:server>
      <pingback:target>http://www.sqlskills.com/blogs/bobb/PermaLink,guid,1f8edffc-9a0a-41b4-bff4-af01d31364e1.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://www.sqlskills.com/blogs/bobb/CommentView,guid,1f8edffc-9a0a-41b4-bff4-af01d31364e1.aspx</wfw:comment>
      <wfw:commentRss>http://www.sqlskills.com/blogs/bobb/SyndicationService.asmx/GetEntryCommentsRss?guid=1f8edffc-9a0a-41b4-bff4-af01d31364e1</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I've been able to coordinate being home and the Portland (Oregon) SQL Server user
group's meeting schedule, so next week I'll be speaking "at home" for a change. I'm
giving a talk on one of my favorite features for developers in SQL Server 2008, Spatial
Data support. Because it's relatively common these days to see GPS not only in cars
but also in "carry along" devices, cell phones, cameras, and other hi-tech toys I
don't personally possess, I called this talk "SQL Server spatial data for the masses".
If you're at all interested in SQL Server or storing, processing, and visualizing
spatial data and databases, I'll see you there.
</p>
        <p>
WHEN: 
<br />
Thursday, July 24th - 6:30 PM
</p>
        <p>
WHERE: 
<br />
SQLSoft+<br />
1500 NW Bethany Blvd.<br />
Suite 285<br />
Beaverton, Oregon OR 97007
</p>
        <p>
You may want to RVSP to Ken Starnes at <a href="mailto:kstarnes@kdsa.com">kstarnes@kdsa.com</a> so
he can save you a seat.
</p>
        <img width="0" height="0" src="http://www.sqlskills.com/blogs/bobb/aggbug.ashx?id=1f8edffc-9a0a-41b4-bff4-af01d31364e1" />
        <br />
        <hr />
This blog is sponsored by <a href="http://www.sqlskills.com">SQLSkills</a>. 
</body>
      <title>I'm speaking at Portland SQL Server Users Group next Thursday</title>
      <guid isPermaLink="false">http://www.sqlskills.com/blogs/bobb/PermaLink,guid,1f8edffc-9a0a-41b4-bff4-af01d31364e1.aspx</guid>
      <link>http://www.sqlskills.com/blogs/bobb/2008/07/17/ImSpeakingAtPortlandSQLServerUsersGroupNextThursday.aspx</link>
      <pubDate>Thu, 17 Jul 2008 19:01:56 GMT</pubDate>
      <description>&lt;p&gt;
I've been able to coordinate being home and the Portland (Oregon) SQL Server user
group's meeting schedule, so next week I'll be speaking "at home" for a change. I'm
giving a talk on one of my favorite features for developers in SQL Server 2008, Spatial
Data support. Because it's relatively common these days to see GPS not only in cars
but also in "carry along" devices, cell phones, cameras, and other hi-tech toys I
don't personally possess, I called this talk "SQL Server spatial data for the masses".
If you're at all interested in SQL Server or storing, processing, and visualizing
spatial data and databases, I'll see you there.
&lt;/p&gt;
&lt;p&gt;
WHEN: 
&lt;br&gt;
Thursday, July 24th - 6:30 PM
&lt;/p&gt;
&lt;p&gt;
WHERE: 
&lt;br&gt;
SQLSoft+&lt;br&gt;
1500 NW Bethany Blvd.&lt;br&gt;
Suite 285&lt;br&gt;
Beaverton, Oregon OR 97007
&lt;/p&gt;
&lt;p&gt;
You may want to RVSP to Ken Starnes at &lt;a href="mailto:kstarnes@kdsa.com"&gt;kstarnes@kdsa.com&lt;/a&gt; so
he can save you a seat.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.sqlskills.com/blogs/bobb/aggbug.ashx?id=1f8edffc-9a0a-41b4-bff4-af01d31364e1" /&gt;
&lt;br /&gt;
&lt;hr /&gt;
This blog is sponsored by &lt;a href="http://www.sqlskills.com"&gt;SQLSkills&lt;/a&gt;. </description>
      <comments>http://www.sqlskills.com/blogs/bobb/CommentView,guid,1f8edffc-9a0a-41b4-bff4-af01d31364e1.aspx</comments>
      <category>SQL Server 2008</category>
    </item>
    <item>
      <trackback:ping>http://www.sqlskills.com/blogs/bobb/Trackback.aspx?guid=9d6bc1fb-f158-4348-8d68-e1941c6a0c0d</trackback:ping>
      <pingback:server>http://www.sqlskills.com/blogs/bobb/pingback.aspx</pingback:server>
      <pingback:target>http://www.sqlskills.com/blogs/bobb/PermaLink,guid,9d6bc1fb-f158-4348-8d68-e1941c6a0c0d.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://www.sqlskills.com/blogs/bobb/CommentView,guid,9d6bc1fb-f158-4348-8d68-e1941c6a0c0d.aspx</wfw:comment>
      <wfw:commentRss>http://www.sqlskills.com/blogs/bobb/SyndicationService.asmx/GetEntryCommentsRss?guid=9d6bc1fb-f158-4348-8d68-e1941c6a0c0d</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I've noticed that some folks have written PowerShell scripts that execute against
a list of servers. In the scripts, they read the names of the servers from XML files.
But the SQL Server PowerShell provider in RC0 has a useful "component" called
SQLRegistration; its "path" is SQLSERVER:\SQLRegistration that they can use instead. 
</p>
        <p>
This path permits enumeration and manipulation of the (SQL) servers and
server groups that are defined using SQL Server Management Studio. The SQLRegistration
path is not specific to server or instance, but to the SSMS user that's signed on.
For example, on the same physical machine, SQLRegistration for the Windows user bobb
reflects bobb's settings in SSMS. SQLRegistration for user mary (on the same machine)
would reflect mary's SSMS settings. There is no SQLSERVER:\SQLRegistration\{machinename}\{instancename}
path, just SQLSERVER:\SQLRegistration.
</p>
        <p>
SQLRegistration contains two "subdirectories", called "Central Management Server Group"
and "Database Engine Server Group". These are equivalent to SSMS' "Central Management
Servers" and "Local Server Groups" folders, respectively. 
</p>
        <p>
So rather than write custom XML files that hold information about groups of servers
you can use the built-in Registration store. You can import and export registration
information to keep team members' view of SQL Servers and groups consistant using
SSMS.
</p>
        <p>
Because I've been writing PowerShell scripts against the provider's Policy and DataCollection
stores, I thought it would be fun to program SQLRegistration. I found the Microsoft.SqlServer.Management.Registration
namespace in BOL (which is RC0 is really called Microsoft.SqlServer.Management.Smo.Registration,
BOL says this will change before RTM) and was about to code against the RegisteredServer
and ServerGroup classes, when I realized that Registration was a simple hierarchies
of servers and groups. Just like directories and files. And the built-in groups each
have a "mode" property that's value is "d". Registered Servers have a blank mode property.
Hmmm...
</p>
        <p>
So, at the PowerShell prompt 
<br />
&gt; cd 'SQLSERVER:\sqlregistration\Database Engine Server Group'<br />
&gt; new-item MyNewGroup
</p>
        <p>
creates a new directory (ServerGroup) named MyNewGroup. Well then, a registered
server should be a file.
</p>
        <p>
&gt; new-item MyNewServer -itemtype file
</p>
        <p>
New-Item : SQL Server PowerShell provider error: This provider only supports the<br />
creation of new Server Groups or Server Registrations. Please specify "directory"<br />
to create a new Server Group or "registration" to create a new Server Registration. 
</p>
        <p>
So this should work?
</p>
        <p>
&gt; new-item MyNewServer -itemtype registration
</p>
        <p>
New-Item : SQL Server PowerShell provider error: Please specify a connection string
using the -Value parameter.
</p>
        <p>
&gt; new-item MyNewServer -itemtype registration -Value "server=mynewserver;integrated
security=true"<br />
&gt;
</p>
        <p>
Yep. This creates a new server registration using the connection parameters that you
specify. How cool is that? No other part of the SQL SERVER PowerShell provider that
I'm aware of supports the new-item cmdlet/operation. Because the SQLRegistration represent
fairly simple items and hierarchies new-item is supported here. No custom programming
needed (although you can use the SMO classes if you'd rather), just treat it as you
would file system.
</p>
        <p>
A couple of caveats. In RC0 SSMS and PowerShell SQLRegisgtration sync up when you
open SSMS but if you're using both at once, the sync to SSMS isn't immediate. Sometimes
refresh doesn't appear to show the changes you made in PowerShell. Eventually it will
show them if you refresh multiple times or restart SSMS. And after deleting
a Server Registration in SSMS, I still had to run "rm MyNewServer" in PowerShell to
get rid of it there. Also, I use "integrated security=sspi" rather than "integrated
security=true" in my ADO.NET connection strings. This seems to bother SSMS which reports
an error in configuration. Use "true" rather than "sspi" when creating registrations
through PowerShell.<br /></p>
        <img width="0" height="0" src="http://www.sqlskills.com/blogs/bobb/aggbug.ashx?id=9d6bc1fb-f158-4348-8d68-e1941c6a0c0d" />
        <br />
        <hr />
This blog is sponsored by <a href="http://www.sqlskills.com">SQLSkills</a>. 
</body>
      <title>Programming SQLRegistration in the SQL Server PowerShell Provider</title>
      <guid isPermaLink="false">http://www.sqlskills.com/blogs/bobb/PermaLink,guid,9d6bc1fb-f158-4348-8d68-e1941c6a0c0d.aspx</guid>
      <link>http://www.sqlskills.com/blogs/bobb/2008/07/08/ProgrammingSQLRegistrationInTheSQLServerPowerShellProvider.aspx</link>
      <pubDate>Tue, 08 Jul 2008 07:23:58 GMT</pubDate>
      <description>&lt;p&gt;
I've noticed that some folks have written PowerShell scripts that execute against
a list of servers. In the scripts, they read the names of the servers from XML files.
But the SQL Server PowerShell provider in RC0&amp;nbsp;has a useful "component" called
SQLRegistration; its "path" is SQLSERVER:\SQLRegistration that they can use instead. 
&lt;/p&gt;
&lt;p&gt;
This path permits enumeration and manipulation&amp;nbsp;of&amp;nbsp;the (SQL) servers and
server groups that are defined using SQL Server Management Studio. The SQLRegistration
path is not specific to server or instance, but to the SSMS user that's signed on.
For example, on the same physical machine, SQLRegistration for the Windows user bobb
reflects bobb's settings in SSMS. SQLRegistration for user mary (on the same machine)
would reflect mary's SSMS settings. There is no SQLSERVER:\SQLRegistration\{machinename}\{instancename}
path, just SQLSERVER:\SQLRegistration.
&lt;/p&gt;
&lt;p&gt;
SQLRegistration contains two "subdirectories", called "Central Management Server Group"
and "Database Engine Server Group". These are equivalent to SSMS' "Central Management
Servers" and "Local Server Groups" folders, respectively. 
&lt;/p&gt;
&lt;p&gt;
So rather than write custom XML files that hold information about groups of servers
you can use the built-in Registration store. You can import and export registration
information to keep team members' view of SQL Servers and groups consistant using
SSMS.
&lt;/p&gt;
&lt;p&gt;
Because I've been writing PowerShell scripts against the provider's Policy and DataCollection
stores, I thought it would be fun to program SQLRegistration. I found the Microsoft.SqlServer.Management.Registration
namespace in BOL&amp;nbsp;(which is RC0 is really called Microsoft.SqlServer.Management.Smo.Registration,
BOL says this will change before RTM) and was about to code against the RegisteredServer
and ServerGroup classes, when I realized that Registration was a simple hierarchies
of servers and groups. Just like directories and files. And the built-in groups each
have a "mode" property that's value is "d". Registered Servers have a blank mode property.
Hmmm...
&lt;/p&gt;
&lt;p&gt;
So, at the PowerShell prompt 
&lt;br&gt;
&amp;gt; cd 'SQLSERVER:\sqlregistration\Database Engine Server Group'&lt;br&gt;
&amp;gt; new-item MyNewGroup
&lt;/p&gt;
&lt;p&gt;
creates a new directory (ServerGroup) named MyNewGroup. Well then,&amp;nbsp;a registered
server should be a file.
&lt;/p&gt;
&lt;p&gt;
&amp;gt; new-item MyNewServer -itemtype file
&lt;/p&gt;
&lt;p&gt;
New-Item : SQL Server PowerShell provider error: This provider only supports the&lt;br&gt;
creation of new Server Groups or Server Registrations. Please specify "directory"&lt;br&gt;
to create a new Server Group or "registration" to create a new Server Registration. 
&lt;/p&gt;
&lt;p&gt;
So this should work?
&lt;/p&gt;
&lt;p&gt;
&amp;gt; new-item MyNewServer -itemtype registration
&lt;/p&gt;
&lt;p&gt;
New-Item : SQL Server PowerShell provider error: Please specify a connection string
using the -Value parameter.
&lt;/p&gt;
&lt;p&gt;
&amp;gt; new-item MyNewServer -itemtype registration -Value "server=mynewserver;integrated
security=true"&lt;br&gt;
&amp;gt;
&lt;/p&gt;
&lt;p&gt;
Yep. This creates a new server registration using the connection parameters that you
specify. How cool is that? No other part of the SQL SERVER PowerShell provider that
I'm aware of supports the new-item cmdlet/operation. Because the SQLRegistration represent
fairly simple items and hierarchies new-item is supported here. No custom programming
needed (although you can use the SMO classes if you'd rather), just treat it as you
would file system.
&lt;/p&gt;
&lt;p&gt;
A couple of caveats. In RC0 SSMS and PowerShell SQLRegisgtration sync up when you
open SSMS but if you're using both at once, the sync to SSMS isn't immediate. Sometimes
refresh doesn't appear to show the changes you made in PowerShell. Eventually it will
show them if you refresh multiple times&amp;nbsp;or restart SSMS.&amp;nbsp;And after deleting
a Server Registration in SSMS, I still had to run "rm MyNewServer" in PowerShell to
get rid of it there. Also, I use "integrated security=sspi" rather than "integrated
security=true" in my ADO.NET connection strings. This seems to bother SSMS which reports
an error in configuration. Use "true" rather than "sspi" when creating registrations
through PowerShell.&lt;br&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.sqlskills.com/blogs/bobb/aggbug.ashx?id=9d6bc1fb-f158-4348-8d68-e1941c6a0c0d" /&gt;
&lt;br /&gt;
&lt;hr /&gt;
This blog is sponsored by &lt;a href="http://www.sqlskills.com"&gt;SQLSkills&lt;/a&gt;. </description>
      <comments>http://www.sqlskills.com/blogs/bobb/CommentView,guid,9d6bc1fb-f158-4348-8d68-e1941c6a0c0d.aspx</comments>
      <category>SQL Server 2008</category>
    </item>
    <item>
      <trackback:ping>http://www.sqlskills.com/blogs/bobb/Trackback.aspx?guid=d8e8a2e5-7a04-4cec-be07-d232a7271c2c</trackback:ping>
      <pingback:server>http://www.sqlskills.com/blogs/bobb/pingback.aspx</pingback:server>
      <pingback:target>http://www.sqlskills.com/blogs/bobb/PermaLink,guid,d8e8a2e5-7a04-4cec-be07-d232a7271c2c.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://www.sqlskills.com/blogs/bobb/CommentView,guid,d8e8a2e5-7a04-4cec-be07-d232a7271c2c.aspx</wfw:comment>
      <wfw:commentRss>http://www.sqlskills.com/blogs/bobb/SyndicationService.asmx/GetEntryCommentsRss?guid=d8e8a2e5-7a04-4cec-be07-d232a7271c2c</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I received a question today about whether I'd converted my Policy-Based Management
examples using SMO (see the multi-part "Programming Policy-Based Management with
SMO" series, starting <a href="http://www.sqlskills.com/blogs/bobb/2008/03/17/ProgrammingPolicyBasedManagementWithSMOPart1Intro.aspx">here</a>)
from C# to PowerShell yet. I did do this a while ago; they're available as a script
download on the SQLskills website (look on the "Past Conferences" page under TechEd
2008). But...
</p>
        <p>
Since then RC0 has changed PBM a bit. The multipart name policy can't use ExecutionMode.Enforce
any more, so I changed it to ExecutionMode.None which equates to "On Demand" in the
SSMS dialog. There was a change to one of the enumerated constant names too.
So the updated scripts for RC0 are posted as part of this blog entry.
</p>
        <p>
As long as I was working on parts of the PowerShell provider for SQL Server and SMO,
I decided to put together an example of using the DataCollection APIs as well. The
script creates a custom DataCollection Collection Set. That's pretty straightforward.
Using the CollectionStore instance just use the correct location in the provider hierarchy
and get a CollectionStore instance.
</p>
        <p>
# set a collectionstore object for the default instance on local machine<br />
$colpath = ('SQLSERVER:\DataCollection\' + (get-item env:\computername).Value + '\default')<br />
$col = get-item $colpath
</p>
        <p>
Then create a CollectionSet instance with (your CollectionStore $col is specifed as
a parameter to new-object) and one or more CollectionItems in the CollectionSet. Then
set the CollectionSet and CollectionItem proprties and call Create. This script enclosed
as well, named CreateCustomCollectionSet.ps1. 
</p>
        <p>
As an aside, I've enclosed a script called start_smo_sql.ps1. This is a script that
I call at PowerShell startup if I know the SQL Server provider is already installed.
It sets convenience variables for long SMO namespace names, paths to the default Server,
CollectionStore, etc. It's not invoked from my main PowerShell profile %UserProfile%\My
Documents\WindowsPowerShell\profile.ps1 which is executed by all PowerShell shells/this
user. Instead it's invoked from %UserProfile%\My Documents\WindowsPowerShell\Microsoft.SqlServer.Management.PowerShell.sqlps_profile.ps1.
This profile is only executed when I'm using SQLPS.exe, the SQL Server-specific custom
shell. It's quite cool that PowerShell accomodates separate profiles for custom shells.
</p>
        <p>
The toughest part in creating a custom collection set is that the XML schema for collection
set properties has been updated in one of the CTPs, but not updated in Books Online
RC0. The updated XML schema can be obtained by executing:
</p>
        <p>
use msdb<br />
select * from syscollector_collector_types
</p>
        <p>
and using the parameter_schema column to get the schema you need to figure out how
to create a validatable parameter. My T-SQL custom collection set used a parameter
with an XML namespace on the root element (only) that looked like this:
</p>
        <p>
&lt;ns:TSQLQueryCollector xmlns:ns="DataCollectorType"&gt;<br />
        &lt;Query&gt;<br />
          &lt;Value&gt;select * from
sys.dm_exec_query_stats&lt;/Value&gt;<br />
          &lt;OutputTable&gt;dm_exec_query_stats&lt;/OutputTable&gt;<br />
        &lt;/Query&gt;<br />
&lt;/ns:TSQLQueryCollector&gt;
</p>
        <a href="http://www.sqlskills.com/blogs/bobb/content/binary/ps_demo_scripts.zip">ps_demo_scripts.zip
(3.23 KB)</a>
        <img width="0" height="0" src="http://www.sqlskills.com/blogs/bobb/aggbug.ashx?id=d8e8a2e5-7a04-4cec-be07-d232a7271c2c" />
        <br />
        <hr />
This blog is sponsored by <a href="http://www.sqlskills.com">SQLSkills</a>. 
</body>
      <title>Using PowerShell to program SQL Server's Policies and Data Collection</title>
      <guid isPermaLink="false">http://www.sqlskills.com/blogs/bobb/PermaLink,guid,d8e8a2e5-7a04-4cec-be07-d232a7271c2c.aspx</guid>
      <link>http://www.sqlskills.com/blogs/bobb/2008/07/08/UsingPowerShellToProgramSQLServersPoliciesAndDataCollection.aspx</link>
      <pubDate>Tue, 08 Jul 2008 07:11:57 GMT</pubDate>
      <description>&lt;p&gt;
I received a question today about whether I'd converted my Policy-Based Management
examples using SMO (see the multi-part&amp;nbsp;"Programming Policy-Based Management with
SMO" series, starting &lt;a href="http://www.sqlskills.com/blogs/bobb/2008/03/17/ProgrammingPolicyBasedManagementWithSMOPart1Intro.aspx"&gt;here&lt;/a&gt;)
from C# to PowerShell yet. I did do this a while ago; they're available as a script
download on the SQLskills website (look on the "Past Conferences" page under TechEd
2008). But...
&lt;/p&gt;
&lt;p&gt;
Since then RC0 has changed PBM a bit. The multipart name policy can't use ExecutionMode.Enforce
any more, so I changed it to ExecutionMode.None which equates to "On Demand" in the
SSMS dialog. There was a change to one of the enumerated constant&amp;nbsp;names&amp;nbsp;too.
So the updated scripts for RC0&amp;nbsp;are posted as part of this blog entry.
&lt;/p&gt;
&lt;p&gt;
As long as I was working on parts of the PowerShell provider for SQL Server and SMO,
I decided to put together an example of using the DataCollection APIs as well. The
script creates a custom DataCollection Collection Set.&amp;nbsp;That's pretty straightforward.
Using the CollectionStore instance just use the correct location in the provider hierarchy
and get a CollectionStore instance.
&lt;/p&gt;
&lt;p&gt;
# set a collectionstore object for the default instance on local machine&lt;br&gt;
$colpath = ('SQLSERVER:\DataCollection\' + (get-item env:\computername).Value + '\default')&lt;br&gt;
$col = get-item $colpath
&lt;/p&gt;
&lt;p&gt;
Then create a CollectionSet instance with (your CollectionStore $col is specifed as
a parameter to new-object) and one or more CollectionItems in the CollectionSet. Then
set the CollectionSet and CollectionItem proprties and call Create. This script enclosed
as well, named CreateCustomCollectionSet.ps1. 
&lt;/p&gt;
&lt;p&gt;
As an aside, I've enclosed a script called start_smo_sql.ps1. This is a script that
I call at PowerShell startup if I know the SQL Server provider is already installed.
It sets convenience variables for long SMO namespace names, paths to the default Server,
CollectionStore, etc. It's not invoked from my main PowerShell profile %UserProfile%\My
Documents\WindowsPowerShell\profile.ps1 which is executed by all PowerShell shells/this
user. Instead it's invoked from %UserProfile%\My Documents\WindowsPowerShell\Microsoft.SqlServer.Management.PowerShell.sqlps_profile.ps1.
This profile is only executed when I'm using SQLPS.exe, the SQL Server-specific custom
shell. It's quite cool that PowerShell accomodates separate profiles for custom shells.
&lt;/p&gt;
&lt;p&gt;
The toughest part in creating a custom collection set is that the XML schema for collection
set properties has been updated in one of the CTPs, but not updated in Books Online
RC0. The updated XML schema can be obtained by executing:
&lt;/p&gt;
&lt;p&gt;
use msdb&lt;br&gt;
select * from syscollector_collector_types
&lt;/p&gt;
&lt;p&gt;
and using the parameter_schema column to get the schema you need to figure out how
to create a validatable parameter. My T-SQL custom collection set used a parameter
with an XML namespace on the root element (only) that looked like this:
&lt;/p&gt;
&lt;p&gt;
&amp;lt;ns:TSQLQueryCollector xmlns:ns="DataCollectorType"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Query&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Value&amp;gt;select * from
sys.dm_exec_query_stats&amp;lt;/Value&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;OutputTable&amp;gt;dm_exec_query_stats&amp;lt;/OutputTable&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Query&amp;gt;&lt;br&gt;
&amp;lt;/ns:TSQLQueryCollector&amp;gt;
&lt;/p&gt;
&lt;a href="http://www.sqlskills.com/blogs/bobb/content/binary/ps_demo_scripts.zip"&gt;ps_demo_scripts.zip
(3.23 KB)&lt;/a&gt;&lt;img width="0" height="0" src="http://www.sqlskills.com/blogs/bobb/aggbug.ashx?id=d8e8a2e5-7a04-4cec-be07-d232a7271c2c" /&gt;
&lt;br /&gt;
&lt;hr /&gt;
This blog is sponsored by &lt;a href="http://www.sqlskills.com"&gt;SQLSkills&lt;/a&gt;. </description>
      <comments>http://www.sqlskills.com/blogs/bobb/CommentView,guid,d8e8a2e5-7a04-4cec-be07-d232a7271c2c.aspx</comments>
      <category>SQL Server 2008</category>
    </item>
    <item>
      <trackback:ping>http://www.sqlskills.com/blogs/bobb/Trackback.aspx?guid=da14f597-eeb1-43e1-b86f-9472e6ce1864</trackback:ping>
      <pingback:server>http://www.sqlskills.com/blogs/bobb/pingback.aspx</pingback:server>
      <pingback:target>http://www.sqlskills.com/blogs/bobb/PermaLink,guid,da14f597-eeb1-43e1-b86f-9472e6ce1864.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://www.sqlskills.com/blogs/bobb/CommentView,guid,da14f597-eeb1-43e1-b86f-9472e6ce1864.aspx</wfw:comment>
      <wfw:commentRss>http://www.sqlskills.com/blogs/bobb/SyndicationService.asmx/GetEntryCommentsRss?guid=da14f597-eeb1-43e1-b86f-9472e6ce1864</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Last week at TechEd Developers, I gave a talk on PowerShell and SQL Server. I mentioned
some upcoming changes in RC0, and have just had a chance to check them out. 
</p>
        <p>
The PowerShell provider for SQL Server has been expanded to handle not only a "SQL"
subdirectory (which enumerates database objects) and "SQLPolicy" (which enumerates
the policy-based management objects) but also two new "directories": SQLRegistration
and DataCollection.
</p>
        <p>
SQLRegistration covers the groups and members of "Registered Servers" and before you
ask, yes this is the same Registered Servers that show up in SQL Server Management
Studio. So if you're managing hundreds of servers, you can easier script against any
server or group of "Registered Servers". You don't have to navigate to a different
machine and instance by referencing the name, as I described in <a href="http://www.sqlskills.com/blogs/bobb/2008/03/25/AccessingMultipleServersWithTheSQLServer2008PowerShellProvider.aspx">an
earlier blog entry</a>. Be aware that the registration service takes a while to refresh
registrations. If you define a new registered server in SSMS, it won't show up in
the PowerShell list immediately. Just wait a minute or so...
</p>
        <p>
The DataCollection "subdirectory" allows you to enumerate the database objects and
properties for the data collection feature that is used to populate and control the
performance data warehouse in SQL Server 2008. You navigate through these collections/values
the same way you'd navigate SQL and SQLPolicy. This one isn't doc'd as being part
of the PowerShell provider in  BOL yet.
</p>
        <p>
A couple of other miscellanous changes I noticed:<br />
1. There are no longer separate custom drives for SQL and SQLPolicy as in previous
versions. If you liked these custom drives its easy to add them:<br />
New-PSDrive -Name SQL -Root SQLSERVER:\SQL<br />
New-PSDrive -Name SQLPolicy -Root SQLSERVER:\SQLPolicy<br />
..etc
</p>
        <p>
2. Collection Names are no longer case-sensitive. So: 
</p>
        <p>
dir SQLServer:\SQL\{Computer}\{Instance}\databases 
</p>
        <p>
(where you replace {Computer} and {Instance} with real names) works now with "databases"
being case insensitive. 
</p>
        <img width="0" height="0" src="http://www.sqlskills.com/blogs/bobb/aggbug.ashx?id=da14f597-eeb1-43e1-b86f-9472e6ce1864" />
        <br />
        <hr />
This blog is sponsored by <a href="http://www.sqlskills.com">SQLSkills</a>. 
</body>
      <title>Changes to the SQL Server PowerShell provider in RC0</title>
      <guid isPermaLink="false">http://www.sqlskills.com/blogs/bobb/PermaLink,guid,da14f597-eeb1-43e1-b86f-9472e6ce1864.aspx</guid>
      <link>http://www.sqlskills.com/blogs/bobb/2008/06/09/ChangesToTheSQLServerPowerShellProviderInRC0.aspx</link>
      <pubDate>Mon, 09 Jun 2008 21:59:08 GMT</pubDate>
      <description>&lt;p&gt;
Last week at TechEd Developers, I gave a talk on PowerShell and SQL Server. I mentioned
some upcoming changes in RC0, and have just had a chance to check them out. 
&lt;/p&gt;
&lt;p&gt;
The PowerShell provider for SQL Server has been expanded to handle not only a "SQL"
subdirectory (which enumerates database objects) and "SQLPolicy" (which enumerates
the policy-based management objects) but also two new "directories": SQLRegistration
and DataCollection.
&lt;/p&gt;
&lt;p&gt;
SQLRegistration covers the groups and members of "Registered Servers" and before you
ask, yes this is the same Registered Servers that show up in SQL Server Management
Studio. So if you're managing hundreds of servers, you can easier script against any
server or group of "Registered Servers". You don't have to navigate to a different
machine and instance by referencing the name, as I described in &lt;a href="http://www.sqlskills.com/blogs/bobb/2008/03/25/AccessingMultipleServersWithTheSQLServer2008PowerShellProvider.aspx"&gt;an
earlier blog entry&lt;/a&gt;. Be aware that the registration service takes a while to refresh
registrations. If you define a new registered server in SSMS, it won't show up in
the PowerShell list immediately. Just wait a minute or so...
&lt;/p&gt;
&lt;p&gt;
The DataCollection "subdirectory" allows you to enumerate the database objects and
properties for the data collection feature that is used to populate and control the
performance data warehouse in SQL Server 2008. You navigate through these collections/values
the same way you'd navigate SQL and SQLPolicy. This one isn't doc'd as being part
of the PowerShell provider in&amp;nbsp; BOL yet.
&lt;/p&gt;
&lt;p&gt;
A couple of other miscellanous changes I noticed:&lt;br&gt;
1. There are no longer separate custom drives for SQL and SQLPolicy as in previous
versions. If you liked these custom drives its easy to add them:&lt;br&gt;
New-PSDrive -Name SQL -Root SQLSERVER:\SQL&lt;br&gt;
New-PSDrive -Name SQLPolicy -Root SQLSERVER:\SQLPolicy&lt;br&gt;
..etc
&lt;/p&gt;
&lt;p&gt;
2. Collection Names are no longer case-sensitive. So: 
&lt;/p&gt;
&lt;p&gt;
dir SQLServer:\SQL\{Computer}\{Instance}\databases 
&lt;/p&gt;
&lt;p&gt;
(where you replace {Computer} and {Instance} with real names) works now with "databases"
being case insensitive. 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.sqlskills.com/blogs/bobb/aggbug.ashx?id=da14f597-eeb1-43e1-b86f-9472e6ce1864" /&gt;
&lt;br /&gt;
&lt;hr /&gt;
This blog is sponsored by &lt;a href="http://www.sqlskills.com"&gt;SQLSkills&lt;/a&gt;. </description>
      <comments>http://www.sqlskills.com/blogs/bobb/CommentView,guid,da14f597-eeb1-43e1-b86f-9472e6ce1864.aspx</comments>
      <category>SQL Server 2008</category>
    </item>
    <item>
      <trackback:ping>http://www.sqlskills.com/blogs/bobb/Trackback.aspx?guid=05eeb3a2-cd15-4aee-8b57-2bcbd209b3ac</trackback:ping>
      <pingback:server>http://www.sqlskills.com/blogs/bobb/pingback.aspx</pingback:server>
      <pingback:target>http://www.sqlskills.com/blogs/bobb/PermaLink,guid,05eeb3a2-cd15-4aee-8b57-2bcbd209b3ac.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://www.sqlskills.com/blogs/bobb/CommentView,guid,05eeb3a2-cd15-4aee-8b57-2bcbd209b3ac.aspx</wfw:comment>
      <wfw:commentRss>http://www.sqlskills.com/blogs/bobb/SyndicationService.asmx/GetEntryCommentsRss?guid=05eeb3a2-cd15-4aee-8b57-2bcbd209b3ac</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
SQL Server 2008 RC0 comes with a Readme file and a Release Notes file. It's always
good to read both. In this RC, the readme file contains information on installation
and upgrade, and the Release Notes file contains information about things that have
changed from previous releases.
</p>
        <p>
In RC0, they've changed the syntax/format of a few relevent new features. The changes
affect T-SQL MERGE, the HierarchyID data type's methods, and the Geometry data type's
Latitude/Longitude order. These won't be doc'd in BOL under What's New, because the
What's New section lists new features, not features that have changed since the last
CTP. Reading up on features that have changed will (hopefully) reduce the number of
"why doesn't this code example that I downloaded from a reputable source work?" questions.
</p>
        <p>
In addition to the two new performance features I just blogged about, RC0 also contains
the new "Spatial Builder" API. Isaac has an excellent blog post about this API, with
a (now-)working example. Check out <a href="http://blogs.msdn.com/isaac/archive/2008/05/30/our-upcoming-builder-api.aspx">his
blog</a>, I didn't find this feature mentioned in either "What's New" or "Release
Notes".
</p>
        <img width="0" height="0" src="http://www.sqlskills.com/blogs/bobb/aggbug.ashx?id=05eeb3a2-cd15-4aee-8b57-2bcbd209b3ac" />
        <br />
        <hr />
This blog is sponsored by <a href="http://www.sqlskills.com">SQLSkills</a>. 
</body>
      <title>Don't just read the Readme, read the Release Notes too</title>
      <guid isPermaLink="false">http://www.sqlskills.com/blogs/bobb/PermaLink,guid,05eeb3a2-cd15-4aee-8b57-2bcbd209b3ac.aspx</guid>
      <link>http://www.sqlskills.com/blogs/bobb/2008/06/09/DontJustReadTheReadmeReadTheReleaseNotesToo.aspx</link>
      <pubDate>Mon, 09 Jun 2008 21:20:39 GMT</pubDate>
      <description>&lt;p&gt;
SQL Server 2008 RC0 comes with a Readme file and a Release Notes file. It's always
good to read both. In this RC, the readme file contains information on installation
and upgrade, and the Release Notes file contains information about things that have
changed from previous releases.
&lt;/p&gt;
&lt;p&gt;
In RC0, they've changed the syntax/format of a few relevent new features. The changes
affect T-SQL MERGE, the HierarchyID data type's methods, and the Geometry data type's
Latitude/Longitude order. These won't be doc'd in BOL under What's New, because the
What's New section lists new features, not features that have changed since the last
CTP. Reading up on features that have changed will (hopefully) reduce the number of
"why doesn't this code example that I downloaded from a reputable source work?" questions.
&lt;/p&gt;
&lt;p&gt;
In addition to the two new performance features I just blogged about, RC0 also contains
the new "Spatial Builder" API. Isaac has an excellent blog post about this API, with
a (now-)working example. Check out &lt;a href="http://blogs.msdn.com/isaac/archive/2008/05/30/our-upcoming-builder-api.aspx"&gt;his
blog&lt;/a&gt;, I didn't find this feature mentioned in either "What's New" or "Release
Notes".
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.sqlskills.com/blogs/bobb/aggbug.ashx?id=05eeb3a2-cd15-4aee-8b57-2bcbd209b3ac" /&gt;
&lt;br /&gt;
&lt;hr /&gt;
This blog is sponsored by &lt;a href="http://www.sqlskills.com"&gt;SQLSkills&lt;/a&gt;. </description>
      <comments>http://www.sqlskills.com/blogs/bobb/CommentView,guid,05eeb3a2-cd15-4aee-8b57-2bcbd209b3ac.aspx</comments>
      <category>SQL Server 2008</category>
    </item>
    <item>
      <trackback:ping>http://www.sqlskills.com/blogs/bobb/Trackback.aspx?guid=3c4be33a-1790-4b70-8b66-113eb4a028de</trackback:ping>
      <pingback:server>http://www.sqlskills.com/blogs/bobb/pingback.aspx</pingback:server>
      <pingback:target>http://www.sqlskills.com/blogs/bobb/PermaLink,guid,3c4be33a-1790-4b70-8b66-113eb4a028de.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://www.sqlskills.com/blogs/bobb/CommentView,guid,3c4be33a-1790-4b70-8b66-113eb4a028de.aspx</wfw:comment>
      <wfw:commentRss>http://www.sqlskills.com/blogs/bobb/SyndicationService.asmx/GetEntryCommentsRss?guid=3c4be33a-1790-4b70-8b66-113eb4a028de</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
There's a newer version of SQL Server 2008 (Release Candidate 0) available on MSDN
and Technet.
</p>
        <p>
Another performance-related feature (actually its additional information) allows you
to have better visibility into performance-affecting queries. This information is
available as columns query_hash and query_plan_hash in the sys.dm_exec_query_stats
and sys.dm_exec_requests DMV. There's a really nice illustrative example in Books
Online, so I won't repeat it here. You can use the queries in my last blog post to
experiment with this as well. 
</p>
        <p>
The queries:
</p>
        <p>
SELECT title_id, sum(qty) from sales<br />
group by title_id<br />
having sum(qty) = 30
</p>
        <p>
and
</p>
        <p>
SELECT title_id, sum(qty) from sales<br />
group by title_id<br />
having sum(qty) = 40
</p>
        <p>
are similar enough that they could be parameterized (although they aren't autoparameterized).
Parameterization would save query plan entry storage, rather than allocating a separate
plan for each incantation of the similar query. You can also use this feature, along
with the additional information in sys.dm_exec_query_stats to produce cumulative statistics
(such as avg IOs, elasped time, etc. BOL has a nice query to accumulate similar plans,
the relavent part is simply "GROUP BY query_hash".
</p>
        <p>
But because you have similar queries, should you always have a parameterized query?
What if "...having  sum(qty) = 30" has a completely different plan than "...having
sum(qty) = 130"? You can find this information by looking at query_plan_hash. If two
plans have similar structure but a different query plan, the query_hash value will
be identical but query_plan_hash will be different. That's an indication that parameterization
might not be the way to go; the first query to executed will cache it's plan and the
other query will use the same plan. This is because of a SQL Server behavior known
as parameter sniffing.
</p>
        <p>
Because parameterizing queries is usually one of the first things programmers can
do to affect performance, it helps to know when to parameterize. In addition, many
folks like to start query tuning by tuning the queries (including similar queries
with different parameter values) that are executed most frequently. Query_plan_hash
and query_hash gives you visibility into this important information.
</p>
        <img width="0" height="0" src="http://www.sqlskills.com/blogs/bobb/aggbug.ashx?id=3c4be33a-1790-4b70-8b66-113eb4a028de" />
        <br />
        <hr />
This blog is sponsored by <a href="http://www.sqlskills.com">SQLSkills</a>. 
</body>
      <title>Performance features in SQL Server 2008 RC0 - Hashes for queries and query plans</title>
      <guid isPermaLink="false">http://www.sqlskills.com/blogs/bobb/PermaLink,guid,3c4be33a-1790-4b70-8b66-113eb4a028de.aspx</guid>
      <link>http://www.sqlskills.com/blogs/bobb/2008/06/09/PerformanceFeaturesInSQLServer2008RC0HashesForQueriesAndQueryPlans.aspx</link>
      <pubDate>Mon, 09 Jun 2008 21:02:36 GMT</pubDate>
      <description>&lt;p&gt;
There's a newer version of SQL Server 2008 (Release Candidate 0) available on MSDN
and Technet.
&lt;/p&gt;
&lt;p&gt;
Another performance-related feature (actually its additional information) allows you
to have better visibility into performance-affecting queries. This information is
available as columns query_hash and query_plan_hash in the sys.dm_exec_query_stats
and sys.dm_exec_requests DMV. There's a really nice illustrative example in Books
Online, so I won't repeat it here. You can use the queries in my last blog post to
experiment with this as well. 
&lt;/p&gt;
&lt;p&gt;
The queries:
&lt;/p&gt;
&lt;p&gt;
SELECT title_id, sum(qty) from sales&lt;br&gt;
group by title_id&lt;br&gt;
having sum(qty) = 30
&lt;/p&gt;
&lt;p&gt;
and
&lt;/p&gt;
&lt;p&gt;
SELECT title_id, sum(qty) from sales&lt;br&gt;
group by title_id&lt;br&gt;
having sum(qty) = 40
&lt;/p&gt;
&lt;p&gt;
are similar enough that they could be parameterized (although they aren't autoparameterized).
Parameterization would save query plan entry storage, rather than allocating a separate
plan for each incantation of the similar query. You can also use this feature, along
with the additional information in sys.dm_exec_query_stats to produce cumulative statistics
(such as avg IOs, elasped time, etc. BOL has a nice query to accumulate similar plans,
the relavent part is simply "GROUP BY query_hash".
&lt;/p&gt;
&lt;p&gt;
But because you have similar queries, should you always have a parameterized query?
What if "...having&amp;nbsp; sum(qty) = 30" has a completely different plan than "...having
sum(qty) = 130"? You can find this information by looking at query_plan_hash. If two
plans have similar structure but a different query plan, the query_hash value will
be identical but query_plan_hash will be different. That's an indication that parameterization
might not be the way to go; the first query to executed will cache it's plan and the
other query will use the same plan. This is because of a SQL Server behavior known
as parameter sniffing.
&lt;/p&gt;
&lt;p&gt;
Because parameterizing queries is usually one of the first things programmers can
do to affect performance, it helps to know when to parameterize. In addition, many
folks like to start query tuning by tuning the queries (including&amp;nbsp;similar queries
with different parameter values)&amp;nbsp;that are executed most frequently. Query_plan_hash
and query_hash gives you visibility into this important information.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.sqlskills.com/blogs/bobb/aggbug.ashx?id=3c4be33a-1790-4b70-8b66-113eb4a028de" /&gt;
&lt;br /&gt;
&lt;hr /&gt;
This blog is sponsored by &lt;a href="http://www.sqlskills.com"&gt;SQLSkills&lt;/a&gt;. </description>
      <comments>http://www.sqlskills.com/blogs/bobb/CommentView,guid,3c4be33a-1790-4b70-8b66-113eb4a028de.aspx</comments>
      <category>SQL Server 2008</category>
    </item>
    <item>
      <trackback:ping>http://www.sqlskills.com/blogs/bobb/Trackback.aspx?guid=7a1d241d-5dba-417f-be45-8fd2a785ab07</trackback:ping>
      <pingback:server>http://www.sqlskills.com/blogs/bobb/pingback.aspx</pingback:server>
      <pingback:target>http://www.sqlskills.com/blogs/bobb/PermaLink,guid,7a1d241d-5dba-417f-be45-8fd2a785ab07.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://www.sqlskills.com/blogs/bobb/CommentView,guid,7a1d241d-5dba-417f-be45-8fd2a785ab07.aspx</wfw:comment>
      <wfw:commentRss>http://www.sqlskills.com/blogs/bobb/SyndicationService.asmx/GetEntryCommentsRss?guid=7a1d241d-5dba-417f-be45-8fd2a785ab07</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
There's a newer version of SQL Server 2008 (Release Candidate 0) available on MSDN
and Technet.
</p>
        <p>
There's a couple of features that show up in RC0 that are performance related. One
is a server setting 'optimize for ad hoc workloads'. This one tells SQL Server to
save a "compiled plan stub" in the query cache for adhoc queries, rather than the
query plan that's usually saved. 
</p>
        <p>
You can see these stubs as cacheobjtype 'Compiled Plan Stub' in sys.dm_exec_cached_plans.
And you can see them because trying to resolve a plan_handle to a query plan (using
sys.dm_exec_cached_plans or sys.dm_exec_query_stats) doesn't work for stubs, like
it does for "real" plan handles. Saving a stub rather than the entire plan saves precious
plan cache memory.
</p>
        <p>
Here's a little script to try it out.
</p>
        <p>
sp_configure 'show advanced options',1<br />
reconfigure<br />
go<br />
sp_configure 'optimize for ad hoc workloads',1<br />
reconfigure<br />
go<br />
-- don't use on a production system, clears whole query cache<br />
DBCC FREEPROCCACHE<br />
go<br />
use pubs<br />
go<br />
-- background plans to produce this DMV, note there is a stub for one of these plans<br />
select * from sys.dm_exec_cached_plans<br />
go<br />
-- not autoparameterized, stub produced<br />
SELECT title_id, sum(qty) from sales<br />
group by title_id<br />
having sum(qty) = 30<br />
go<br />
-- you can see the stub<br />
select * from sys.dm_exec_cached_plans<br />
go<br />
-- autoparameterized, whole query plan for parameterized version<br />
SELECT * 
<br />
FROM titles 
<br />
WHERE price = 19.99<br />
go
</p>
        <p>
-- stub for the non-parameterized version, plan for the parameterized version<br />
SELECT usecounts, cacheobjtype, objtype, [text]<br />
FROM sys.dm_exec_cached_plans P<br />
   CROSS APPLY sys.dm_exec_sql_text(plan_handle)<br />
   WHERE [text] NOT LIKE '%dm_exec%'<br />
ORDER BY p.usecounts DESC<br />
-- query plan for stub query handle is not saved returns NULL<br />
SELECT sql.text, p.query_plan 
<br />
FROM sys.dm_exec_query_stats AS qs 
<br />
CROSS APPLY sys.dm_exec_sql_text(sql_handle) sql<br />
CROSS APPLY sys.dm_exec_query_plan(plan_handle) p<br />
WHERE text NOT LIKE '%sys_dm_exec%' AND text NOT LIKE '%msparam_0%'<br />
ORDER BY qs.EXECUTION_COUNT DESC<br />
go
</p>
        <p>
-- set it back, same experiment produces plans not stubs<br />
sp_configure 'show advanced options',1<br />
reconfigure<br />
go<br />
sp_configure 'optimize for ad hoc workloads',0<br />
reconfigure<br />
go
</p>
        <img width="0" height="0" src="http://www.sqlskills.com/blogs/bobb/aggbug.ashx?id=7a1d241d-5dba-417f-be45-8fd2a785ab07" />
        <br />
        <hr />
This blog is sponsored by <a href="http://www.sqlskills.com">SQLSkills</a>. 
</body>
      <title>Performance features in SQL Server 2008 RC0 - Optimize for Adhoc Workloads</title>
      <guid isPermaLink="false">http://www.sqlskills.com/blogs/bobb/PermaLink,guid,7a1d241d-5dba-417f-be45-8fd2a785ab07.aspx</guid>
      <link>http://www.sqlskills.com/blogs/bobb/2008/06/09/PerformanceFeaturesInSQLServer2008RC0OptimizeForAdhocWorkloads.aspx</link>
      <pubDate>Mon, 09 Jun 2008 20:40:47 GMT</pubDate>
      <description>&lt;p&gt;
There's a newer version of SQL Server 2008 (Release Candidate 0) available on MSDN
and Technet.
&lt;/p&gt;
&lt;p&gt;
There's a couple of features that show up in RC0 that are performance related. One
is a server setting 'optimize for ad hoc workloads'. This one tells SQL Server to
save a "compiled plan stub" in the query cache for adhoc queries, rather than the
query plan that's usually saved. 
&lt;/p&gt;
&lt;p&gt;
You can see these stubs&amp;nbsp;as cacheobjtype 'Compiled Plan Stub'&amp;nbsp;in sys.dm_exec_cached_plans.
And you can see them because trying to resolve a plan_handle to a query plan (using
sys.dm_exec_cached_plans or sys.dm_exec_query_stats) doesn't work for stubs, like
it does for "real" plan handles. Saving a stub rather than the entire plan saves precious
plan cache memory.
&lt;/p&gt;
&lt;p&gt;
Here's a little script to try it out.
&lt;/p&gt;
&lt;p&gt;
sp_configure 'show advanced options',1&lt;br&gt;
reconfigure&lt;br&gt;
go&lt;br&gt;
sp_configure 'optimize for ad hoc workloads',1&lt;br&gt;
reconfigure&lt;br&gt;
go&lt;br&gt;
--&amp;nbsp;don't use&amp;nbsp;on a production system, clears whole query cache&lt;br&gt;
DBCC FREEPROCCACHE&lt;br&gt;
go&lt;br&gt;
use pubs&lt;br&gt;
go&lt;br&gt;
-- background plans to produce this DMV, note there is a stub for one of these plans&lt;br&gt;
select * from sys.dm_exec_cached_plans&lt;br&gt;
go&lt;br&gt;
-- not autoparameterized, stub produced&lt;br&gt;
SELECT title_id, sum(qty) from sales&lt;br&gt;
group by title_id&lt;br&gt;
having sum(qty) = 30&lt;br&gt;
go&lt;br&gt;
-- you can see the stub&lt;br&gt;
select * from sys.dm_exec_cached_plans&lt;br&gt;
go&lt;br&gt;
-- autoparameterized, whole query plan for parameterized version&lt;br&gt;
SELECT * 
&lt;br&gt;
FROM titles 
&lt;br&gt;
WHERE price = 19.99&lt;br&gt;
go
&lt;/p&gt;
&lt;p&gt;
-- stub for the non-parameterized version, plan for the parameterized version&lt;br&gt;
SELECT usecounts, cacheobjtype, objtype, [text]&lt;br&gt;
FROM sys.dm_exec_cached_plans P&lt;br&gt;
&amp;nbsp;&amp;nbsp; CROSS APPLY sys.dm_exec_sql_text(plan_handle)&lt;br&gt;
&amp;nbsp;&amp;nbsp; WHERE [text] NOT LIKE '%dm_exec%'&lt;br&gt;
ORDER BY p.usecounts DESC&lt;br&gt;
-- query plan for stub query handle is not saved returns NULL&lt;br&gt;
SELECT sql.text, p.query_plan 
&lt;br&gt;
FROM sys.dm_exec_query_stats AS qs 
&lt;br&gt;
CROSS APPLY sys.dm_exec_sql_text(sql_handle) sql&lt;br&gt;
CROSS APPLY sys.dm_exec_query_plan(plan_handle) p&lt;br&gt;
WHERE text NOT LIKE '%sys_dm_exec%' AND text NOT LIKE '%msparam_0%'&lt;br&gt;
ORDER BY qs.EXECUTION_COUNT DESC&lt;br&gt;
go
&lt;/p&gt;
&lt;p&gt;
-- set it back, same experiment produces plans not stubs&lt;br&gt;
sp_configure 'show advanced options',1&lt;br&gt;
reconfigure&lt;br&gt;
go&lt;br&gt;
sp_configure 'optimize for ad hoc workloads',0&lt;br&gt;
reconfigure&lt;br&gt;
go
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.sqlskills.com/blogs/bobb/aggbug.ashx?id=7a1d241d-5dba-417f-be45-8fd2a785ab07" /&gt;
&lt;br /&gt;
&lt;hr /&gt;
This blog is sponsored by &lt;a href="http://www.sqlskills.com"&gt;SQLSkills&lt;/a&gt;. </description>
      <comments>http://www.sqlskills.com/blogs/bobb/CommentView,guid,7a1d241d-5dba-417f-be45-8fd2a785ab07.aspx</comments>
      <category>SQL Server 2008</category>
    </item>
    <item>
      <trackback:ping>http://www.sqlskills.com/blogs/bobb/Trackback.aspx?guid=df73ce25-1c47-4062-8199-e134c31ffd41</trackback:ping>
      <pingback:server>http://www.sqlskills.com/blogs/bobb/pingback.aspx</pingback:server>
      <pingback:target>http://www.sqlskills.com/blogs/bobb/PermaLink,guid,df73ce25-1c47-4062-8199-e134c31ffd41.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://www.sqlskills.com/blogs/bobb/CommentView,guid,df73ce25-1c47-4062-8199-e134c31ffd41.aspx</wfw:comment>
      <wfw:commentRss>http://www.sqlskills.com/blogs/bobb/SyndicationService.asmx/GetEntryCommentsRss?guid=df73ce25-1c47-4062-8199-e134c31ffd41</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
In a <a href="http://www.sqlskills.com/blogs/bobb/2008/05/16/TraceEventsInADONETEntityFramework.aspx">blog
posting about a few weeks ago</a>, I'd written about noticing a DataSet being created
in an Entity Framework program by using the ADO.NET client trace facility. Entity
Framework programs do (indirectly) cause a DataSet to be created, but its only for
resolving the ProviderInvariantName of the underlying data provider. NOT for anything
related to the functioning of the EntityClient or ObjectContext in any way. I've revised
the original blog posting to remove the DataSet reference, but just in case you already
read it....
</p>
        <p>
The connection string for the EntityClient data provider contains a parameter that
refers to the ProviderInvariantName of the underlying data provider (e.g. System.Data.SqlClient).
Entity Framework validates the underlying data provider name by using the ADO.NET
provider enumerator class DbProviderFactories. DbProviderFactories creates the DataSet
to store the provider information obtained from the machine.config file.
</p>
        <p>
I might have guessed this...as I'd written a whitepaper on the functionality of the
ADO.NET provider model, "<a href="http://msdn.microsoft.com/en-us/library/ms379620.aspx">Generic
Coding with the ADO.NET 2.0 Base Classes and Factories</a>" not more than a few years
ago. Using the DbProviderFactories class is the only way to enumerate the ADO.NET
data providers installed on your machine.
</p>
        <p>
Come to my "End-To-End Tracing with SQL Server 2008 and ADO.NET" talk at <a href="https://www.msteched.com/default.aspx">TechEd</a> next
week and I'll show you the trace.
</p>
        <img width="0" height="0" src="http://www.sqlskills.com/blogs/bobb/aggbug.ashx?id=df73ce25-1c47-4062-8199-e134c31ffd41" />
        <br />
        <hr />
This blog is sponsored by <a href="http://www.sqlskills.com">SQLSkills</a>. 
</body>
      <title>What's the DataSet doing in a trace of an Entity Framework program?</title>
      <guid isPermaLink="false">http://www.sqlskills.com/blogs/bobb/PermaLink,guid,df73ce25-1c47-4062-8199-e134c31ffd41.aspx</guid>
      <link>http://www.sqlskills.com/blogs/bobb/2008/05/30/WhatsTheDataSetDoingInATraceOfAnEntityFrameworkProgram.aspx</link>
      <pubDate>Fri, 30 May 2008 23:48:41 GMT</pubDate>
      <description>&lt;p&gt;
In a &lt;a href="http://www.sqlskills.com/blogs/bobb/2008/05/16/TraceEventsInADONETEntityFramework.aspx"&gt;blog
posting about a few weeks ago&lt;/a&gt;, I'd written about noticing a DataSet being created
in an Entity Framework program by using the ADO.NET client trace facility. Entity
Framework programs do (indirectly) cause a DataSet to be created, but its only for
resolving the ProviderInvariantName of the underlying data provider. NOT for anything
related to the functioning of the EntityClient or ObjectContext in any way. I've revised
the original blog posting to remove the DataSet reference, but just in case you already
read it....
&lt;/p&gt;
&lt;p&gt;
The connection string for the EntityClient data provider contains a parameter that
refers to the ProviderInvariantName of the underlying data provider (e.g. System.Data.SqlClient).
Entity Framework validates the underlying data provider name by using the ADO.NET
provider enumerator class DbProviderFactories. DbProviderFactories creates the DataSet
to store the provider information obtained from the machine.config file.
&lt;/p&gt;
&lt;p&gt;
I might have guessed this...as I'd written a whitepaper on the functionality of the
ADO.NET provider model, "&lt;a href="http://msdn.microsoft.com/en-us/library/ms379620.aspx"&gt;Generic
Coding with the ADO.NET 2.0 Base Classes and Factories&lt;/a&gt;" not more than a few years
ago. Using the DbProviderFactories class is the only way to enumerate the ADO.NET
data providers installed on your machine.
&lt;/p&gt;
&lt;p&gt;
Come to my "End-To-End Tracing with SQL Server 2008 and ADO.NET" talk at &lt;a href="https://www.msteched.com/default.aspx"&gt;TechEd&lt;/a&gt; next
week and I'll show you the trace.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.sqlskills.com/blogs/bobb/aggbug.ashx?id=df73ce25-1c47-4062-8199-e134c31ffd41" /&gt;
&lt;br /&gt;
&lt;hr /&gt;
This blog is sponsored by &lt;a href="http://www.sqlskills.com"&gt;SQLSkills&lt;/a&gt;. </description>
      <comments>http://www.sqlskills.com/blogs/bobb/CommentView,guid,df73ce25-1c47-4062-8199-e134c31ffd41.aspx</comments>
      <category>SQL Server 2008</category>
    </item>
  </channel>
</rss>