<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://sqlblog.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Tibor Karaszi : General</title><link>http://sqlblog.com/blogs/tibor_karaszi/archive/tags/General/default.aspx</link><description>Tags: General</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>Analogy between SQL Server and operating systems</title><link>http://sqlblog.com/blogs/tibor_karaszi/archive/2008/08/08/analogy-between-sql-server-and-operating-systems.aspx</link><pubDate>Fri, 08 Aug 2008 08:25:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:8277</guid><dc:creator>TiborKaraszi</dc:creator><slash:comments>1</slash:comments><comments>http://sqlblog.com/blogs/tibor_karaszi/comments/8277.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/tibor_karaszi/commentrss.aspx?PostID=8277</wfw:commentRss><description>&lt;P&gt;With SQL Server 2008 released, I was thinking back of earlier versions of SQL Server. And I decided to compare them to the MS operating systems. Not a point-in-time comparsion, like "SQL Server version x was released year a, which was the same year that OS y was released.". I'm thinking more of the feel you have for the product. Why would anyone want to do that? I don't know - for fun, perhaps? While writing below I realized that the comparsions/analogies worked better the older the product is. Perhaps a product need to be obsolete for us to have the sentimental feeling required for this type of comparsion? Anyhow,&amp;nbsp;here goes:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;SQL Server 1.x &amp;lt;-&amp;gt; DOS&lt;/STRONG&gt;&lt;BR&gt;(I do know it ran on OS/2, but again this is more about how you feel for the product.)&lt;BR&gt;I know, perhaps not all fair, but think about it. We are talking about command-line environments, or at the best some full-screen character based applications (like edit.exe or saf.exe). And installation was floppy based where the product did fit on a couple of floppies.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;SQL Server 4.x &amp;lt;-&amp;gt; OS/2 or Windows pre-95&lt;/STRONG&gt;&lt;BR&gt;I can't decide here. &lt;BR&gt;OS/2 had the merit that it wasn't a bad OS, but almost no apps were developed for it (think back to version 1.2 and 1.3 and what it was at the time - and what it could have been), and it wasn't a fun environment to work in. Windows pre-95 had the merit of being a GUI which, sort of, brought multitasking to the desktop - but what about robustness? &lt;BR&gt;Same goes for SQL server 4.x. It was revolutionary in some sense, like: Imagine fitting a real RDBMS in a PC? Now smaller businesses can start using "real" RDBMSs. But OTOH, it was very unpolished. Remember the GUI tools? They were really Windows apps&amp;nbsp;where some conversion tool converted them for OS/2. &lt;BR&gt;So, I think it is a draw between OS/2 and Windows pre-95.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;SQL Server 6.x &amp;lt;-&amp;gt; Windows NT 3.x or Windows 9x&lt;/STRONG&gt;&lt;BR&gt;Again, I can't decide.&lt;BR&gt;In one way, SQL Server 6.x was MS first "own" release. But OTOH, the Sybase code base was still there. MS mainly did tool stuff, along with some engine stuff (like ANSI SQL compliance). But it wasn't a re-write of the engine. &lt;BR&gt;This can compare to Windows 9x - the DOS heritage was still there, in some sense.&lt;BR&gt;If you compare SQL Server 6.x to Windows NT 3.x you can also see similarities. NT 3.x was the first versions of the new revolutionary OS from MS. But it still looked like ... old Windows - something you might compare with SQL Server 6.x enterprise Manager.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;SQL Server&amp;nbsp;7.0 &amp;lt;-&amp;gt; NT 4&lt;BR&gt;&lt;/STRONG&gt;I was originally going to put Windows 2000 here, but after thinking a while, I decide for NT 4.&lt;BR&gt;7.0 was the first version of the new architecture. A lot happened, where the engine was all re-written. New stuff was introduced (Profiler, DTS, Olap server). So, at the engine level, we basically got a more modern look-and-feel. &lt;BR&gt;To some extent NT 4 was similar. You got a new GUI (adopted from Windows 9x). The revolution was that you now had an *stable* OS which you also could run as your desktop OS. I bet that many of you (computer nerds)/readers preferred NT 4 instead of Windows 9x at that time. I did. There were some architectural news in the OS as well, like the device driver model (some stuff were moved to kernel mode - if my memory serves me).&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;SQL Server 2000 &amp;lt;-&amp;gt; Windows 2000&lt;BR&gt;&lt;/STRONG&gt;Seems too easy, but think about it.&lt;BR&gt;SQL Server 2000 was when the new architecture matured. IMO, a great release at that time. OK, some would argue that it didn't happened that much between 7.0 and 2000, but maturing and polish of the new architecture is a major thing to me.&lt;BR&gt;Windows 2000 can also be seen as becoming mature - ready to be used in masses. OK, there were some revolutionary new stuff like AD, but you can't expect the analogy to fit 100%. ;-)&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;SQL Server 2005 &amp;lt;-&amp;gt; Vista&lt;/STRONG&gt;&lt;BR&gt;Hmm, is my analogy breaking down here?&lt;BR&gt;I was originally going to put Windows 2003 here. But that was a bit too much going chronologically hand-in-hand. &lt;BR&gt;And I think that XP is a bit unfair (perhaps XP would be a better fit for SQL Server 2000?). &lt;BR&gt;But 2005 did have lots and lots of changes and new features. And so did Vista. Vista has a rather slow adaption rate, and I have the same feeling for SQL Server 2005. Many people seems to wait for Vista+, a perhaps more cleaned-up OS? And some seem to be waiting for SQL Server 2008, even though perhaps not for the same reasons.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;SQL Server 2008 &amp;lt;-&amp;gt; Vista +&lt;/STRONG&gt;&lt;BR&gt;This&amp;nbsp;was unavoidable, considering how we got here. I won't dwell into this, since it is too&amp;nbsp;early to say how we feel about these releases in 10 years from now...&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now why on earth did I write this post? Well, I have been doing some 6 full installations and some 12 database engine installations of SQL Server 2008 the last two days - so I've had a lot of time on my hands. :-)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=8277" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/tibor_karaszi/archive/tags/General/default.aspx">General</category><category domain="http://sqlblog.com/blogs/tibor_karaszi/archive/tags/Historical/default.aspx">Historical</category></item><item><title>Endpoints, Netlibs, IPC and stuff...</title><link>http://sqlblog.com/blogs/tibor_karaszi/archive/2008/05/28/endpoints-netlibs-ipc-and-stuff.aspx</link><pubDate>Wed, 28 May 2008 15:37:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:7020</guid><dc:creator>TiborKaraszi</dc:creator><slash:comments>7</slash:comments><comments>http://sqlblog.com/blogs/tibor_karaszi/comments/7020.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/tibor_karaszi/commentrss.aspx?PostID=7020</wfw:commentRss><description>&lt;P&gt;Its been a while since my last post. No special reason, just a combination of lot of work and I didn't feel I had something pressing to say... &lt;/P&gt;
&lt;P&gt;This topic is basically on how the client app communicates with SQL Server. Not the API level (like ADO or ODBC), or the packet level (TDS), but in between. Basicaly we're talking IPC, Inter Process Communication - in a SQL Server context:&lt;/P&gt;
&lt;P&gt;Here's how I understand it (I probably gonna get some points wrong and you are all welcome to correct me):&lt;/P&gt;
&lt;P&gt;There are network protocols, such as:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;TCP/IP (has routing functionality of course)&lt;/LI&gt;
&lt;LI&gt;NetBEUI (very limited, if any, routing functionality)&lt;/LI&gt;
&lt;LI&gt;IPX (the original protocol for Novell networks)&lt;/LI&gt;
&lt;LI&gt;SNA (mainly used in IBM mainframe and such environments)&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;A network protocol is of little use if we can't send data back and fort between application over that network protocol. So, there are APIs to facilitate IPC:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;NETBIOS (originally developed for NetBEUI, but is also supported over IP (requires WINS or LMHOST for name resolution))&lt;/LI&gt;
&lt;LI&gt;Sockets (not available for NetBEUI AFAIK, only TCP/IP)&lt;/LI&gt;
&lt;LI&gt;Named Pipes (built on top of NETBIOS)&lt;/LI&gt;
&lt;LI&gt;RPC (implemented and available over both NetBEUI and IP)&lt;/LI&gt;
&lt;LI&gt;SPX (as I understand it, the API over IPX)&lt;/LI&gt;
&lt;LI&gt;APPC (program-to-program protocol over SNA)&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;When MS released "their" SQL Server, they needed a way for the client app to communicate to the server. They decided to go for Named Pipes and developed what we call "netlib". I.e., the MS deveopers used the Named Pipes API (which is similar to reading and writing to a file from the programmers perspective) when developing the Named Pipes netlib.&lt;/P&gt;
&lt;P&gt;Over time, new netlibs were developed, where in SQL Server 2000, this culminated in below list:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Shared Memory&amp;nbsp;(only for local connections, obviously)&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;Named Pipes&lt;/LI&gt;
&lt;LI&gt;Sockets&lt;/LI&gt;
&lt;LI&gt;RPC&lt;/LI&gt;
&lt;LI&gt;VIA&lt;/LI&gt;
&lt;LI&gt;SPX&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;There was never a netlib deveoped directly on top of NETBIOS, but indirectly through Named Pipes. Named Pipes uses NETBIOS, which available over IP, and hence is routable. In 2005, the list has shrunk to:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Shared Memory&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;Named Pipes&lt;/LI&gt;
&lt;LI&gt;Sockets&lt;/LI&gt;
&lt;LI&gt;VIA&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;And I have a feeling that in the end Named Pipes will go away. I don't have any experience with VIA, but I believe that it is closer to the metal than Sockets so it might stick around for dedicated AppServer-to-SqlServer networks.&lt;/P&gt;
&lt;P&gt;So, what does above have to do with Endpoints? Well, MS are categorizing netlibs as endpoint nowadays. This makes sense since the netlibs are a "way in" to SQL Server, as are HTTP, Service Broker and Database Mirroring endpoints.&lt;/P&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=7020" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/tibor_karaszi/archive/tags/General/default.aspx">General</category><category domain="http://sqlblog.com/blogs/tibor_karaszi/archive/tags/Network/default.aspx">Network</category></item><item><title>The SQL Server script repository</title><link>http://sqlblog.com/blogs/tibor_karaszi/archive/2008/03/03/the-sql-server-script-repository.aspx</link><pubDate>Mon, 03 Mar 2008 20:18:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:5420</guid><dc:creator>TiborKaraszi</dc:creator><slash:comments>5</slash:comments><comments>http://sqlblog.com/blogs/tibor_karaszi/comments/5420.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/tibor_karaszi/commentrss.aspx?PostID=5420</wfw:commentRss><description>&lt;P&gt;How come I've missed this? I don't know, but I'm writing this blog post so to bookmark this site. &lt;/P&gt;
&lt;P&gt;You'll find a handful of scripts, mainly using Dynamic Management Views and Functions, to monitor various aspects of SQL Server.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.microsoft.com/technet/scriptcenter/scripts/sql/sql2005/default.mspx?mfr=true"&gt;http://www.microsoft.com/technet/scriptcenter/scripts/sql/sql2005/default.mspx?mfr=true&lt;/A&gt;&lt;/P&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=5420" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/tibor_karaszi/archive/tags/General/default.aspx">General</category></item><item><title>Is statistics over non-indexed columns updated by index rebuild?</title><link>http://sqlblog.com/blogs/tibor_karaszi/archive/2007/08/09/is-statistics-over-non-indexed-columns-updated-by-index-rebuild.aspx</link><pubDate>Thu, 09 Aug 2007 15:18:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:2165</guid><dc:creator>TiborKaraszi</dc:creator><slash:comments>10</slash:comments><comments>http://sqlblog.com/blogs/tibor_karaszi/comments/2165.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/tibor_karaszi/commentrss.aspx?PostID=2165</wfw:commentRss><description>&lt;P&gt;Short answer: &lt;STRONG&gt;no&lt;/STRONG&gt;.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This question came up today in the MCT discussion group. My gut instinct said no, but I wanted to test it to be certain. But first a brief background:&lt;/P&gt;
&lt;P&gt;You can rebuild an index using DBCC DBREINDEX or in 2005 (and now preferred) ALTER INDEX ... REBUILD. Rebuilding an index internally creates a new index and when that has been done, drops the old index. &lt;/P&gt;
&lt;P&gt;So it is pretty obvious that we also get new statistics for that index (based on all data, not sampled, just as when we do CREATE INDEX). As an aside, reorganizing does *not* update the statistics...&lt;/P&gt;
&lt;P&gt;But what about statistics over non-indexed columns? SQL Server can create this by itself, assuming you didn't turn off this database option. These are named something like _WA_sys. And you can also create these explicitly usinf CREATE STATISTICS. &lt;/P&gt;
&lt;P&gt;A few words about below script: I wanted to use the STATS_DATE function to retrieve datetime for when the statistics was built/updated. But STATS_DATE doesn't seem to work on statistics only; it expect an id for an index... So, this is why I use DBCC SHOW_STATISTICS instead. And, unfortunately, DBCC SHOW_STATISTICS only display the statistics build time with minute precision. This is why I have a WAITFOR with &amp;gt; 1 minute in between the operations. &lt;/P&gt;
&lt;P&gt;I got the same resuld whether or not I rebuild a clustered or non-clustered index on the table or even when specifying ALL indexes. Script:&lt;/P&gt;
&lt;P&gt;USE tempdb&lt;BR&gt;SET NOCOUNT ON&lt;BR&gt;IF OBJECT_ID('t') IS NOT NULL DROP TABLE t&lt;BR&gt;CREATE TABLE t(c1 int identity, c2 char(5))&lt;BR&gt;INSERT INTO t (c2)&lt;BR&gt;&amp;nbsp;SELECT TOP 10000 'Hello' FROM syscolumns a, syscolumns b&lt;/P&gt;
&lt;P&gt;CREATE CLUSTERED INDEX x1 ON t(c2)&lt;BR&gt;CREATE STATISTICS s1 ON t(c1)&lt;/P&gt;
&lt;P&gt;SELECT ' ' AS "Before mass modification"&lt;BR&gt;DBCC SHOW_STATISTICS('t', 'x1') WITH STAT_HEADER, NO_INFOMSGS&lt;BR&gt;DBCC SHOW_STATISTICS('t', 's1') WITH STAT_HEADER, NO_INFOMSGS&lt;/P&gt;
&lt;P&gt;WAITFOR DELAY '00:01:02'&lt;/P&gt;
&lt;P&gt;INSERT INTO t (c2)&lt;BR&gt;&amp;nbsp;SELECT TOP 10000 'Hi' FROM syscolumns a, syscolumns b&lt;BR&gt;SELECT ' ' AS "Before index rebuild"&lt;BR&gt;DBCC SHOW_STATISTICS('t', 'x1') WITH STAT_HEADER, NO_INFOMSGS&lt;BR&gt;DBCC SHOW_STATISTICS('t', 's1') WITH STAT_HEADER, NO_INFOMSGS&lt;/P&gt;
&lt;P&gt;WAITFOR DELAY '00:01:02'&lt;/P&gt;
&lt;P&gt;--ALTER INDEX x1 ON t REBUILD&lt;BR&gt;ALTER INDEX ALL ON t REBUILD&lt;BR&gt;SELECT ' ' AS "After index rebuild"&lt;BR&gt;DBCC SHOW_STATISTICS('t', 'x1') WITH STAT_HEADER, NO_INFOMSGS&lt;BR&gt;DBCC SHOW_STATISTICS('t', 's1') WITH STAT_HEADER, NO_INFOMSGS&lt;BR&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=2165" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/tibor_karaszi/archive/tags/General/default.aspx">General</category><category domain="http://sqlblog.com/blogs/tibor_karaszi/archive/tags/Maintenance/default.aspx">Maintenance</category></item><item><title>No Notification Services in SQL Server 2008</title><link>http://sqlblog.com/blogs/tibor_karaszi/archive/2007/08/03/no-notification-services-in-sql-server-2008.aspx</link><pubDate>Fri, 03 Aug 2007 08:08:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:2081</guid><dc:creator>TiborKaraszi</dc:creator><slash:comments>9</slash:comments><comments>http://sqlblog.com/blogs/tibor_karaszi/comments/2081.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/tibor_karaszi/commentrss.aspx?PostID=2081</wfw:commentRss><description>&lt;P&gt;If you have been wondering where Notification Services (NS) is in the prior CTPs of SQL Server 2008, you now have the answer. NS will not be carried forward to SQL Server 2008. Here's a quote from July CTP readme:&lt;/P&gt;
&lt;P&gt;"SQL Server Notification Services will not be included as a component of SQL Server 2008, but will continue to be supported as part of the SQL Server 2005 product support life-cycle. Moving forward, support for key notification scenarios will be incorporated into SQL Server Reporting Services. Existing Reporting Services functionality, such as data driven subscriptions, addresses some of the notification requirements. Features to support additional notification scenarios may be expected in future releases. "&lt;/P&gt;
&lt;P&gt;So, now we know. &lt;/P&gt;
&lt;P&gt;I've been delivering training of SQL Server 2005 for a while now, and one of the courses has a module on NS. Over time, I gradually adapted to the fact that almost no-one was interested in NS and nowadays I just give a brief overwiew of what NS is, and the basics of creating an NS solution. Funny thing is that when you "get" NS, you realize that it is a neat piece of infrastructural software, taking writing some code off your hands. I guess that there hasn't been enough interest in NS to carry it forward to next release, but that it pure speculation from my side...&lt;/P&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=2081" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/tibor_karaszi/archive/tags/General/default.aspx">General</category></item><item><title>Will SQL Server 2008 ship February 27?</title><link>http://sqlblog.com/blogs/tibor_karaszi/archive/2007/07/17/will-sql-server-2008-ship-february-28.aspx</link><pubDate>Tue, 17 Jul 2007 15:05:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:1770</guid><dc:creator>TiborKaraszi</dc:creator><slash:comments>9</slash:comments><comments>http://sqlblog.com/blogs/tibor_karaszi/comments/1770.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/tibor_karaszi/commentrss.aspx?PostID=1770</wfw:commentRss><description>&lt;P&gt;No.&lt;/P&gt;
&lt;P&gt;Let me elaborate a bit. You might have seen and read about the feb 27 launch of SQL Server 2008. Now, in MS lingua, "launch" is not the same as "ship" or "release to manufacturing" (RTM). So, the Feb 27 event is a marketing and awareness event. RTM will be later.&lt;/P&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=1770" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/tibor_karaszi/archive/tags/General/default.aspx">General</category></item><item><title>Want to get rid of "Compact Edition" from Books Online?</title><link>http://sqlblog.com/blogs/tibor_karaszi/archive/2007/07/13/want-to-get-rid-of-compact-edition-from-books-online.aspx</link><pubDate>Fri, 13 Jul 2007 17:17:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:1710</guid><dc:creator>TiborKaraszi</dc:creator><slash:comments>3</slash:comments><comments>http://sqlblog.com/blogs/tibor_karaszi/comments/1710.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/tibor_karaszi/commentrss.aspx?PostID=1710</wfw:commentRss><description>&lt;P&gt;I'm sure that some of you have been annoyed when searching or using the index and found a hit, thinking it looks strange, only to realize that you are looking at&amp;nbsp;a "Compact Edition" topic. This has happened to me more than once. &lt;/P&gt;
&lt;P&gt;We just had a discussion about this in the MVP group and Umachandar Jayachandran (aka UC) have use this great tip. &lt;/P&gt;
&lt;P&gt;Apparently we can remove collections from Books Online.&amp;nbsp;If you use the index in Books Online and type "Help Coll", you will find and entry named "Help Collection [SQL Server]". Here you can remove "SQL Server 2005 Compact Edition", and later add it back in if you wish. &lt;/P&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=1710" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/tibor_karaszi/archive/tags/Documentation/default.aspx">Documentation</category><category domain="http://sqlblog.com/blogs/tibor_karaszi/archive/tags/General/default.aspx">General</category></item><item><title>Are execution plans for functions cached?</title><link>http://sqlblog.com/blogs/tibor_karaszi/archive/2007/06/14/are-execution-plans-for-functions-cached.aspx</link><pubDate>Thu, 14 Jun 2007 17:08:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:1468</guid><dc:creator>TiborKaraszi</dc:creator><slash:comments>0</slash:comments><comments>http://sqlblog.com/blogs/tibor_karaszi/comments/1468.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/tibor_karaszi/commentrss.aspx?PostID=1468</wfw:commentRss><description>&lt;P&gt;Obviously, were talking about multi-statement functions, since&amp;nbsp;in-line functions are just views in the end.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My gut feeling for this is "yes", but I wanted to be absolutely certain. So here goes:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Create a function in Adventureworks&lt;/LI&gt;
&lt;LI&gt;Use that function in a SELECT statement&lt;/LI&gt;
&lt;LI&gt;Check if a plan exists in the plan cache for above&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;USE Adventureworks&lt;BR&gt;GO&lt;/P&gt;
&lt;P&gt;IF OBJECT_ID('fn') IS NOT NULL DROP FUNCTION fn&lt;BR&gt;GO&lt;/P&gt;
&lt;P&gt;CREATE FUNCTION fn(@rg uniqueidentifier)&lt;BR&gt;RETURNS @tbl TABLE(SalesOrderDetailID int NOT NULL PRIMARY KEY, OrderQty smallint NOT NULL)&lt;BR&gt;AS&lt;BR&gt;BEGIN&lt;BR&gt;INSERT INTO @tbl(SalesOrderDetailID, OrderQty)&lt;BR&gt;&amp;nbsp;SELECT SalesOrderDetailID, OrderQty FROM sod WHERE rowguid = @rg&lt;BR&gt;RETURN&lt;BR&gt;END&lt;BR&gt;GO&lt;/P&gt;
&lt;P&gt;SELECT * FROM fn('80667840-F962-4EE3-96E0-AECA108E0D4F')&lt;BR&gt;GO&lt;/P&gt;
&lt;P&gt;SELECT cp.cacheobjtype, cp.plan_handle, qp.query_plan&lt;BR&gt;&amp;nbsp;FROM sys.dm_exec_cached_plans cp &lt;BR&gt;&amp;nbsp;CROSS APPLY sys.dm_exec_query_plan(cp.plan_handle) AS qp&lt;BR&gt;&amp;nbsp;WHERE qp.objectid&amp;nbsp; = OBJECT_ID('fn')&lt;/P&gt;
&lt;P&gt;IF OBJECT_ID('fn') IS NOT NULL DROP FUNCTION fn&lt;/P&gt;
&lt;P&gt;Note the execution plan in XML format picked up from sys.dm_exec_query_plan. If you executed the query in grid format, you can cklick on it, and then save the XML as a file. Rename the file extension to .sqlplan and open that file in SSMS. You can now see the plan for this function graphically.&lt;/P&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=1468" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/tibor_karaszi/archive/tags/General/default.aspx">General</category></item><item><title>Whats in the default trace?</title><link>http://sqlblog.com/blogs/tibor_karaszi/archive/2007/03/12/whats-in-the-default-trace.aspx</link><pubDate>Mon, 12 Mar 2007 09:23:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:967</guid><dc:creator>TiborKaraszi</dc:creator><slash:comments>1</slash:comments><comments>http://sqlblog.com/blogs/tibor_karaszi/comments/967.aspx</comments><wfw:commentRss>http://sqlblog.com/blogs/tibor_karaszi/commentrss.aspx?PostID=967</wfw:commentRss><description>&lt;P&gt;As you probably know, there's a trace running by default in SQL Server 2005. The directory for the trace file is the SQL Server log directory, and you can turn off and on this trace with sp_configure. &lt;/P&gt;
&lt;P&gt;But how do we find out what events and columns are traced to this? We use a trace function and some trace catalog views:&lt;/P&gt;
&lt;P&gt;The function fn_trace_geteventinfo returns what columns and events are captured by a configured trace. But we don't want to see the column id and event id, we want the names. So we join this to the following functions:&lt;BR&gt;sys.trace_events&lt;BR&gt;sys.trace_categories&lt;BR&gt;sys.trace_columns&lt;/P&gt;
&lt;P&gt;Here's the end result:&lt;/P&gt;
&lt;P&gt;SELECT cat.name AS CategoryName, e.name AS EventName, c.name AS ColumnName &lt;BR&gt;FROM fn_trace_geteventinfo(1) AS rt&lt;BR&gt;&amp;nbsp;INNER JOIN sys.trace_events AS e&lt;BR&gt;&amp;nbsp;&amp;nbsp; ON rt.eventid = e.trace_event_id&lt;BR&gt;&amp;nbsp;INNER JOIN sys.trace_columns AS c&lt;BR&gt;&amp;nbsp;&amp;nbsp; ON rt.columnid = c.trace_column_id &lt;BR&gt;&amp;nbsp;INNER JOIN sys.trace_categories AS cat&lt;BR&gt;&amp;nbsp;&amp;nbsp; ON e.category_id = cat.category_id&lt;BR&gt;ORDER BY CategoryName, EventName, ColumnName&lt;BR&gt;&lt;/P&gt;
&lt;P&gt;And here's one with only category and event:&lt;/P&gt;
&lt;P&gt;SELECT DISTINCT cat.name AS CategoryName, e.name AS EventName&lt;BR&gt;FROM fn_trace_geteventinfo(1) AS rt&lt;BR&gt;&amp;nbsp;INNER JOIN sys.trace_events AS e&lt;BR&gt;&amp;nbsp;&amp;nbsp; ON rt.eventid = e.trace_event_id&lt;BR&gt;&amp;nbsp;INNER JOIN sys.trace_categories AS cat&lt;BR&gt;&amp;nbsp;&amp;nbsp; ON e.category_id = cat.category_id&lt;BR&gt;ORDER BY CategoryName, EventName&lt;/P&gt;&lt;img src="http://sqlblog.com/aggbug.aspx?PostID=967" width="1" height="1"&gt;</description><category domain="http://sqlblog.com/blogs/tibor_karaszi/archive/tags/General/default.aspx">General</category><category domain="http://sqlblog.com/blogs/tibor_karaszi/archive/tags/Tools/default.aspx">Tools</category></item></channel></rss>