tag:blogger.com,1999:blog-358923042009-03-01T02:40:58.627-08:00SQL+CLRSQL Server 2005 from a developer's perspectivenohorsehttp://www.blogger.com/profile/05236079390128087517noreply@blogger.comBlogger14125tag:blogger.com,1999:blog-35892304.post-20155925535023107652007-01-03T10:18:00.000-08:002007-01-03T13:00:01.486-08:00The Chipmonks on VirtualizationHere is a link to a 30 minute <a href="http://www.nohorse.com/sqlclr/media/virtualization_primer.wmv">talk on Virtualization for Multnomah County</a>. There was a problem with recording the audio, so this one-hour presentation turned into a 30-minute chipmonk fest.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35892304-2015592553502310765?l=sqlclr.blogspot.com'/></div>nohorsehttp://www.blogger.com/profile/05236079390128087517noreply@blogger.com0tag:blogger.com,1999:blog-35892304.post-1162883339063135742006-11-06T23:08:00.000-08:002006-11-06T23:10:53.853-08:00Situational awareness with SqlContext<span xmlns=""><p>It's often handy for your code to know where it's running. I have a habit coding data access classes that use the caching mechanisms built into the System.Web namespace. These components can only use that cache when the assembly is hosted in IIS. This creates issues when I'm building unit tests that exercise the those classes outside of IIS. To avoid bogus caching errors the class can check to see if it's hosted by IIS by checking HttpContext.Current. If it's null then don't attempt to cache. If it's there, then go ahead and use it.<br /></p><p>SQL Server exposes a similar context to your managed code called SqlContext. SqlContext has a number of methods to allow you to tap into the Sql Session that is calling your code. A simple check to SqlContext.IsAvailable will let you know if you're running on the server. Beyond that, you can explore the SqlContext.WindowsIdentity, TriggerContext or the Pipe. These will be topics of other posts, but for now we'll stick to basics. <br /></p><p>It's possible for your managed stored procedures to perform data access. This feels a little inside out, but you can create an ADO connection inside your managed code and perform queries or updates. If you do this, you should use a special connection string that is only available when running on the server. Here is some code:<br /></p><p>String conncetionString<br/>If(SqlContext.IsAvailable){<br/> connectionString = "context connection=true";<br/>}else{<br/> conncetionString = GetYourRegularConnectionString();<br/>}<br/>SqlConnection con = new SqlConnection(connectionString);<br/>…<br /></p><p>This simple check will allow you to write code that will run on the server, and still allow you to cover the code with unit tests. Hmmm…that's nice.</p></span><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35892304-116288333906313574?l=sqlclr.blogspot.com'/></div>nohorsehttp://www.blogger.com/profile/05236079390128087517noreply@blogger.com0tag:blogger.com,1999:blog-35892304.post-1162535146042084462006-11-02T22:25:00.000-08:002006-11-02T22:29:17.906-08:00I Yield for Table-Value functions<span xmlns=""><p>One of the coolest set of complimentary features in SQL Server 2005 and Visual Studio 2005 can be found in the ability to code a Table-Value function using C#. In this exercise we will create a simple SQL Function in C# that returns a SQL table. Coding a Table-Value Function requires implementing two methods. The first method represents the entry point of the function. We decorate the method signature with some additional information defining the structure of the returned table, as well as naming the other method in the class that will return the columns for the table itself. Start by creating a new database project and connecting it to your sample database. We will not be using any data tables, so any database will do. Add a new function to the project and call it "SampleTable". All table value functions return IEnumerable. There are a number of framework classes that implement this interface in the System.Collections namespace. A new language enhancement in C# greatly simplifies the implementation of IEnumerable: the yield keyword. Yield allows you to return from the function in the middle of a loop. The internal state of the loop is maintained and the function can be called multiple times, with each successive call returning the next value in the loop until the loop is exhausted.<br /></p><p><img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://www.nohorse.com/sqlclr/images/sampletable.png" border="0" /><br /></p><p>Here we see the fully coded function. Attributes define the column definition of the return table. It's a little unfortunate that this definition is a string, so there is no compile time error checking possible. Internal to the method we define one array for each column, fill it up with data and then loop thru each item. Notice that because we can only return a single value from the function, we package up each row to be return as an array of objects. The yield will return one row at a time. The other method attribute is the FillRowMethodName. This is the name of a method that SQL Server will call for each row fetched to redefine the columns. It will accept a generic object, and one out parameter for each column defined in the TableDefinition.<br /></p><p><br /> </p><p><img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://www.nohorse.com/sqlclr/images/fillrow.png" border="0" /><br /></p><p>Our FillRow function gets passed the return value from SampleTable as an object, and one parameter for each column in the table. Its purpose is to explode the object into its constituent elements and fill in the needed columns. Notice how our two methods are tightly bound to each other. FillRow must have complete knowledge SampleTable implementation.<br /></p><p>Go ahead and deploy your project from the build menu, then switch over to SQL Server Management Studio to test your work.<br /></p><p><img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://www.nohorse.com/sqlclr/images/sampletableresults.png" border="0" /><br /></p><p>That was pretty darn easy if you ask me, and not that much code.<br /></p></span><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35892304-116253514604208446?l=sqlclr.blogspot.com'/></div>nohorsehttp://www.blogger.com/profile/05236079390128087517noreply@blogger.com0tag:blogger.com,1999:blog-35892304.post-1161585190322065192006-10-22T23:33:00.000-07:002006-10-27T14:37:09.446-07:00Drop Express and Go Pro<span xmlns=""><p>So far I've been using Visual C# 2005 Express edition to compile my CLR classes. Those classes can be loaded into SQL using T-SQL scripts and a deployment drop-point shared between the two environments. Visual Studio 2005 and SQL Server 2005 enjoy a level of integration that could shorten this deployment path. The version of the IDE that ships with Visual C# Express is missing a few pieces that I'll need to exercise these integration options, so we'll be saying goodbye to Express and load Visual Studio 2005 Professional Edition. I'm a bit tempted to try using Orcas, but with my newness, I better stick to the shipping product. Again, I'll be loading this on my Client PC, not the SQL Server (just in case you were wondering). I'm going to perform a custom install, skip installing SQL Express, VB.Net, J#, C++, and Crystal. All of our exercises will be in C#, and we have a real Instance of SQL Server 2005 Enterprise Edition as a deployment target. </p><img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://www.nohorse.com/sqlclr/images/labconfig.png" border="0" /><br /><p><br />While the install is running, now might be a good time to review the configuration we will be using for the remainder of our adventures: two (2) physical machines, the Server is running Windows 2003 R2, has Virtual Server 2005 R2 loaded as well as application roles for IIS and Active Directory Domain Controller. A Virtual Machine has been created on the server running Windows 2003 R2 and has SQL Server 2005 Enterprise installed. The other physical machine is acting as my development workstation and is loaded with Windows Vista CTP, Office 2007 and Visual Studio 2005 Professional Edition. It would be possible to re-create this lab environment using a single machine with Virtual Server. You would need quite a bit of memory, but it would be possible. The server role we have not talked about yet is Active Directory. Because we are using Windows Integrated Security as the only access method for SQL Server, it's important to actually build up an Active Directory network or hold your user account and computer domain members. Active Directory is where we may need to set up service accounts (user accounts that services can run under) as well as any groups. I can't stress enough how important it is to understand Active Directory Security. If you are not running a domain controller on your home network, take the plunge. Just don't load up too much other stuff on that same server. Domain Controllers have a special flavor (or smell) to them and I would not suggest running SQL Server on one. The exception to this is Small Business Server that is a special all-in-one version of Windows Server 2003 that gives you one stop shopping. I believe an instance of SQL Server gets loaded along with Active Directory, SharePoint, Exchange, and some other stuff. </p><img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://www.nohorse.com/sqlclr/images/serverexplorerassemblies.png" border="0" /><br /><p>Meanwhile, back at the freshly installed IDE of Visual Studio 2005, let's try to get a function to deploy the fast way. Just for grins, I'll create a connection to my SQL Server using the Server Explorer. I notice that along with my usual database objects (Tables, Stored Procedures, Functions…) I also have a section for Assemblies. Sounds encouraging. I'm going to code up a dummy project that I would like to be my SQL function library. In "Visual C#" I'll pick "SQL Server Project". Please note that this is different from the "Database Project" in the "Other Project Types". I'll call mine "ManagedSqlLibrary". Once the Project is loaded, I'll associate my SQL Server Connection and Add a new User-Defined Function. I'll call my function EasyDeploy.cs and we get the following code generated for us: </p><br /><img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://www.nohorse.com/sqlclr/images/easydeploy.png" border="0" /><br /><p>We can see quite a few things going on in the code. For one, we get a new namespace Microsoft.SqlServer.Server that has a part to play in the attribute that is decorating our function. We also see that this function is a partial class of a bigger class library called UserDefinedFunctions. If I want to deploy this to SQL Server I simply select "Deploy" from the "Build" Menu. Back over in Server Explorer, if I refresh, I see that some stuff was definitely deployed. Too easy!</p><br /><img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://www.nohorse.com/sqlclr/images/managedsqllibrarydeployed.png" border="0" /><br /><p>So how to test? There is a Test.sql file conveniently located in the "Test Scripts" folder of the project. Let's add our own script called "TestEasyDeploy" containing some simple testing code, set it as the default test script and Run. I experience an interesting dialog telling me that the firewall on my machine is currently blocking remote debugging. I opt to unblock the ports, but get another error about it not being able to do so. I suspect Vista is the culprit and dive into the control panel looking to unblock TCP Port 135 for DCOM and UDP 4500/ UDP 500 for IPSEC. The final solution was to add DevEnv.exe (the IDE) to the Application Exception list on the Firewall. </p><br /><img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://www.nohorse.com/sqlclr/images/easydeplyoutput.png" border="0" /><br /><p><br />So we've found a much simpler way to build and deploy our SQLCLR objects during development</p></span><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35892304-116158519032206519?l=sqlclr.blogspot.com'/></div>nohorsehttp://www.blogger.com/profile/05236079390128087517noreply@blogger.com0tag:blogger.com,1999:blog-35892304.post-1161323317909392332006-10-19T22:46:00.000-07:002006-10-27T14:37:40.426-07:00An Argument for Managed FunctionsTo be honest, I’m having a hard time resolving when you would actually want to run managed code in SQL Server. This might be a reflection of my newness to the concept, but in general is seems there are limited, very specialized cases (like complex math or financial functions) where you would need it. Then it hit me: you can share utility functions with your applications. <br /><br />Here is the scenario: you have a business rules utility library that has a bunch of static methods for validating data. Said library is chuck full of regular expressions you downloaded from web sites (where people really know how to write them) and you’ve wrapped them all with friendly names like IsSocialSecurityNumber() and IsDate(). The later even accounts for leap year and is a complete mystery to you.<br /><br />Now you’re tasked with importing data from external source and you’ve decided the simplest way to do this is straight into SQL server. You’d like to save yourself a ton of effort by leveraging those regular expressions and now you can.<br /><br /><p><a href="http://www.nohorse.com/sqlclr/samplecode/DataInputValidation.cs.txt" target="sample" ><img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://www.nohorse.com/sqlclr/samplecode/DataInputValidation.png" border="0" ></a><br />Compile your code using visual studio into a class library called ValidationLibray.dll and move it to a deployment drop point that SQL Server can see.<br /><br />Next, create the assembly in SQL Server and create new SQL Functions to call your external ones. </p><p><a href="http://www.nohorse.com/sqlclr/samplecode/validationlibrary.sql.txt" target="sample"><img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://www.nohorse.com/sqlclr/samplecode/ValidationLibrary.png" border="0" /></a><br />Now you can leverage your managed code in SQL as well as your .Net apps and have one codebase for simple validations. Pretty cool.<br /><img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://www.nohorse.com/sqlclr/samplecode/goodbad.png" border="0"/><br />I did notice that SQL is much pickier about what code it will allow to run. For instance, if you are a fan of the lazy load pattern for your classes (like I am), you’ll be disappointed that SQL considers this code “Unsafe”. So I ended up re-writing my class (even to the extent of marking private properties readonly) so it would load into SQL Server. </p><p><br /><a href="http://www.nohorse.com/sqlclr/samplecode/lazyloadValidation.cs.txt" target="sample"><img style="DISPLAY: block; MARGIN: 0px auto 10px; CURSOR: hand; TEXT-ALIGN: center" alt="" src="http://www.nohorse.com/sqlclr/samplecode/lazyloadvalidation.png" border="0" ></a><br />Another thing I noticed right off is that while I’m used to using Boolean types in C# (bool) there is no Boolean in SQL Server. I got lucky and used bit for the return type of my function. SQL is doing some implicit type conversion for me. It’s more common for me to use Int for my Boolean functions in SQL, but bit is the same as int (bit 1 = int 1) so no big deal there.<br /><br />I hope to find more good reasons to incorporate the new CLR support in SQL Server, but I’m still skeptical and worry about performance. </p><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35892304-116132331790939233?l=sqlclr.blogspot.com'/></div>nohorsehttp://www.blogger.com/profile/05236079390128087517noreply@blogger.com0tag:blogger.com,1999:blog-35892304.post-1161243693727042062006-10-19T00:41:00.000-07:002006-10-19T00:46:08.370-07:00VM Tip #3 Get Small<span xmlns=""><p>VHDs get big, really big. You might think an OS and a bunch of software is big, but just go look at your VHD. It's huge. I just installed Windows Server 2003 R2 and SQL Server 2005 on a fresh image and it's over 6GB. Does that sound right? Whether it does or not really isn't the point, over time you will eventually end up with a bloated VHD. When you do, follow these steps:<br /></p><p>On the Guest OS:<br /></p><ol><li>Get rid of all the junk files you have laying around, run disk cleanup, empty the recycle bin.<br /></li><li>Defrag your drive using a tool that moves all the used space to the top of the drive.*<br /></li><li>Run the Precompact.exe utility. **<br /></li><li>Shut Down the Guest OS<br /></li></ol><p>On the Virtual Server:<br /></p><ol><li>Inspect and then Compact the disk using the Virtual Server Admin web. ***<br /></li></ol><p>* Here is the defrag utility I use:<br /></p><p><a href="http://www.flexomizer.com/PermaLink,guid,ce99367e-158c-487a-879d-b32145cc1957.aspx">http://www.flexomizer.com/PermaLink,guid,ce99367e-158c-487a-879d-b32145cc1957.aspx</a><br /> </p><p>** You can find precompact.exe on the Virtual Machine Additions ISO that came with VPC or Virtual Server.<br /></p><p>*** If your using VPC, then you should run the Hard Disk Wizard and make sure and check the Compact Option</p></span><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35892304-116124369372704206?l=sqlclr.blogspot.com'/></div>nohorsehttp://www.blogger.com/profile/05236079390128087517noreply@blogger.com0tag:blogger.com,1999:blog-35892304.post-1161240734793730882006-10-18T23:52:00.000-07:002006-10-19T00:38:39.136-07:00Giving SQL some Class<span xmlns=""><p>One of the fancy new features in SQL 2005 is the ability to run Managed Code (C# or what-have-you) on SQL Server. That's where this blog gets its name. We will be exploring many facets of this integration but first, let's just jump in with a simple "Hello World" exercise. SQL treats your class code like any other object in the database, first you have to code the class and build into an assembly. Then you deploy your assembly to SQL using the CREATE ASSEMBLY statement. To build an assembly and a class we need some flavor of Visual Studio. Just for fun, I'm going to use Visual C# 2005 Express because it's free (and only a 30MB download) and I've never checked it out. The Installer gives you the option of installing SQL Express, but that's just going to confuse me so I skip that. I'll also skip the 200+MB MSDN library install because I'll be getting my help online.<br /></p><p>Firing up the C# IDE I'm creating a new Class Library Project called HelloCLR. I'll Code a simple class called Say and a public property called Hello. It looks something like this:<br /></p><p><span style="font-family:Courier New"><span style="color:blue">using</span> System;<br/><span style="color:blue">using</span> System.Collections.Generic;<br/><span style="color:blue">using</span> System.Text;<br/><br/><span style="color:green">//please notice there is no Namespace defined <br/>//more on this later<br/><br/></span>public class Say {<br/> public static string Hello() {<br/> return "Hello From Managed Code!";<br/> }<br/>}<br/><br /> </span></p><p>I'll need to create a place to put this assembly, so I create a folder on my SQL Server box and grant myself some rights to it. In a production environment, we would not be creating shares on the SQL Server, but for now it's OK. Later on we'll talk about deployment issues. Now I'll build my solution and move it out to my deployment drop point.<br/><br/>C:\Projects\HelloCLR\HelloCLR\bin\Release\HelloCLR.dll<br/>…Move this to…<br/>\\NoSQL2005\DeployDropPoint<br/><br/>We are done coding, so fire up SQL Server Management Studio on the client machine and attach to our SQL Server instance. I notice I don't even have a testing database set up, so I'll create a new one that will hold all our exercises and call it SqlClrDB just for fun. Once selected in the Object explorer, I'll hit the New Query button. And attempt to add my assembly to the database with the following script:<br/><br /> </p><p><span style="font-family:Courier New">create assembly HelloCLR<br/>from 'c:\DeployDropPoint\HelloCLR.dll'<br/><br /> </span></p><p>My command completed successfully. Now to access my Hello() method I'm going to have to wrap it in a SQL Function. So let's do that:<br /></p><p><span style="font-family:Courier New">create function HelloClr<span style="color:gray">()</span> returns nvarchar<span style="color:gray">(</span><span style="color:fuchsia">max</span><span style="color:gray">)</span> as external name HelloCLR<span style="color:gray">.</span>Say<span style="color:gray">.</span>Hello<span style="font-size:10pt"><br /> </span></span></p><p>and finally to see the fruits of out labor:<span style="font-family:Courier New; font-size:10pt"><br /> </span></p><p><span style="font-family:Courier New"><span style="color:blue">select</span> dbo<span style="color:gray">.</span>HelloCLR<span style="color:gray">()<span style="font-size:10pt"><br /> </span></span></span></p><p>but I got an error instead!<br /></p><p><span style="font-family:Courier New">Msg 6263, Level 16, State 1, Line 1<br /></span></p><p><span style="font-family:Courier New">Execution of user code in the .NET Framework is disabled. Enable "clr enabled" configuration option.<span style="font-size:8pt"><br /> </span></span></p><p>Such a bummer. Now what? Seems the default install is to disable the .Net Framework. One way to turn this on is to remote into your SQL Server and run the Surface Area Configuration tool. There is a CLR Integration option that you can enable. If that sounds like too much fooling around with the mouse, you can also issue this:<br /></p><p><span style="font-family:Courier New">sp_configure <span style="color:red">'clr enabled'</span><span style="color:gray">,</span> 1<br/>go<br/><span style="color:blue">reconfigure<br/></span>go<br /></span></p><p><br/>and finally, when we re-issue the call to our function:<br /></p><p><span style="font-family:Courier New"><span style="color:blue">select</span> dbo<span style="color:gray">.</span>HelloCLR<span style="color:gray">()<br /></span></span></p><p><span style="font-family:Courier New">------------------------<br /></span></p><p><span style="font-family:Courier New">Hello From Managed Code!<br /></span></p><p><span style="font-family:Courier New">(1 row(s) affected)<br /></span></p><p><br /> </p><p>What did we learm from this exersize?<br /></p><ol><li>You can load your Managed Code Assemblies into SQL Server 2005.<br /></li><li>You can call static methods from you classes if you wrap them in a SQL Function.<br /></li><li>We hope to learm more about namespace and how they affect assemble loads.<br /></li><li>The CLR is disabled by default when you install SQL Server 2005.<br /></li><li>There are deployment issues moving your assembly to a location where SQL Server can see them.<br /></li><li>Hello world in the SQLCLR world is just as boring as it is in any new platform.</li></ol></span><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35892304-116124073479373088?l=sqlclr.blogspot.com'/></div>nohorsehttp://www.blogger.com/profile/05236079390128087517noreply@blogger.com0tag:blogger.com,1999:blog-35892304.post-1161229536670239642006-10-18T20:45:00.000-07:002006-10-19T00:51:33.680-07:00Virtual Server and Virtual PC<span xmlns=""><p>I noticed that there is a new version of Virtual PC on the way for 2007. I read from the brief that support for Vista was added so I thought I'd check it out on my Tablet. I've used Virtual Server on a daily basis for a while now, and VS is the cornerstone of a virtualization effort going on at the office. I blindly loaded VPC2007 on Vista, uninstalled VS, and loaded my VHDs. With a few barks and grunts, VPC was able to load my VS VHDs just fine. I started poking around on the simplified interface and immediately felt functionality freefall. Assuming VS bias I started researching the differences and immediately found a great article from MS clearly explaining the differences:<br /></p><p><a href="http://www.microsoft.com/downloads/details.aspx?familyid=8ED0A6CB-0F24-408E-AF8F-51EDF508D361&displaylang=en">http://www.microsoft.com/downloads/details.aspx?familyid=8ED0A6CB-0F24-408E-AF8F-51EDF508D361&displaylang=en</a><br /> </p><p>In a nutshell, VPC 2007 is a great product if…<br /></p><ol><li>Your running Vista as the host OS and are having troubles with the new User Account Control and your Virtual Server.<br /></li><li>Your using a single PC for server and client.<br /></li><li>You like a richer experience like dragging and dropping files between VMs and hearing sounds.<br /></li><li>You want to try out Vista in a VM.<br /></li></ol><p>On the other hand some of us appreciate a greater level of control and don't really care about ease of use. So…<br /></p><p>Virtual Server 2005 R2 SP1 is a great product if…<br /></p><ol><li>You running it on a server<br /></li><li>You don't care about Vista quite yet<br /></li><li>Said to yourself "Who needs drag and drop when you can just create a file share on the V-LAN" when you read #3 above<br /></li><li>Would like to use BOTH of your CPUs<br /></li></ol><p>I'll prolly keep VPC on my tablet, but that's really the only place it makes sense for me. The rest will run Virtual Server.</p></span><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35892304-116122953667023964?l=sqlclr.blogspot.com'/></div>nohorsehttp://www.blogger.com/profile/05236079390128087517noreply@blogger.com0tag:blogger.com,1999:blog-35892304.post-1161069255641155702006-10-17T00:14:00.000-07:002006-10-19T00:56:31.090-07:00VM Tip #2 Use Remote Desktop Connection<span xmlns=""><p>Once you get to the point of being able to see your VM on the LAN, I drop the web admin console and that goofy ActiveX control in favor of a Remote Desktop Connection. Not only is the user experience so much more pleasant (like being able to full-screen) but you also have additional features like the ability to expose client drives to the VM to simplify moving things around. This is especially handy when your Remote Desktop Client is the Virtual Server itself. I've noticed in some instances (like when the VM is not attached to a Domain) that Remote Desktop cannot resolve the machine name properly. I've been able to resolve this by creating a Virtual Network that includes the Guest OS and the Virtual Server NIC. Once the Client OS is attached to both the Virtual Server NIC and the Virtual LAN, the name resolution kicked in. My suggestion is to always attach you VMs to the same domain as the Virtual Server and the Client machines that are accessing it. Windows Integrated Security plays much nicer when you don't have to deal with domain boundary issues.<br /></p><p>If this sounds too complicated, and your running your VMs on your laptop, you might want to look into Virtual PC. It gives you the improved user experience without having to go thru RDC. Be advised that there are less features and you limited to a single processor.</p></span><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35892304-116106925564115570?l=sqlclr.blogspot.com'/></div>nohorsehttp://www.blogger.com/profile/05236079390128087517noreply@blogger.com0tag:blogger.com,1999:blog-35892304.post-1161069235235920802006-10-17T00:13:00.000-07:002006-10-17T00:13:55.246-07:00Sql 2005 Installation (part 2)<span xmlns=""><p>OK, a few days later and I'm not really sure where I stopped. I'll fire up the VM and see where we are at…<br /></p><p>Looks like SQL completed installing on the server, and I'll test that by remoting in and launching the SQL Server Management Studio, connecting to localhost and there I see databases. All is good. Now I'm not really hip to running all the client tools on the server, so I'm going to install just the client tools on my client workstation, laptop, whatever. In my case it's a AMD Shuttle running the Vista CTP, so I'm taking some chances using beta software. I'd suggest using an XP box or another Windows 20003 Server instance. Either way, it a good idea to get the client tools on a client and the SQL Server on a server.<br /></p><p>The client tools setup screen default to installing nothing. So I'm going to select Management Tools, Business Intelligence Development, the SDK, and SQLXML from the Client Components group as well as Books Online from the documentation. If I need the sample databases later, I'll get them when I need them. I prefer to build up my databases from scratch so I can really feel the pain.<br /></p><p>Something I'm completely ignoring here is security. In my lab environment I'm a domain admin. It's typically a bad idea to run with such privileges, but I'm more concerned with feature additions to SQL Server 2005 and I will be creating a variety of lowered privileged user accounts as we go.<br /></p><p>Client Setup is complete and I'll verify my connectivity the same way I did on the server, by running the Management Studio and connecting to my instance using the server name of NOSQL2005. You should use whatever machine name you installed you instance on.<br /></p><p>The Management Studio in the replacement for Enterprise Manager and Query Analyzer from SQL 2000. The Business Intelligence Studio is an IDE for creating SSIS Packages that replaced MTS Packages. There are some pretty fundamental shifts in this version. As I understand things, MTS and SSIS are so different, that there is no upgrade path. You basically need to rethink and rebuild. This should be a major bummer for organization that reply heavily on MTS packages and SQL jobs. There may be quite the market for good SSIS developers over the next few years.<br /></p><p>That's it for getting set up. We now have a client machine, a server set up on a virtual machine and all the software loaded. We will be taking "A Developer's Guild to SQL Server 2005" one chapter at a time recreating each example. This could take months <span style="font-family:Wingdings">J</span><br /> </p><p><br /> </p></span><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35892304-116106923523592080?l=sqlclr.blogspot.com'/></div>nohorsehttp://www.blogger.com/profile/05236079390128087517noreply@blogger.com0tag:blogger.com,1999:blog-35892304.post-1160639977320120762006-10-12T00:59:00.000-07:002006-10-17T00:15:26.070-07:00Sql 2005 Installation (part 1)<span xmlns=""><p>I'm installing SQL2005 Enterprise right out of the box on a fresh install of Windows Server 2003 R2. Installing Prerequisites is the first dialog. This includes the .NET Framework 2.0, SQL Native Client, and "Support Files". The Frameworks is a no brainer: we'll need that for the CLR integration. SQL Native Client is a new direct data access client. Funny that after so many years of generifying things with ODBC and ADO that we are again going with proprietary clients. I like it actually and it's not that new, "Classic" ADO.Net also had a specific SQL Client. The "Support Files" is a little ambiguous though. I wonder what's really in there. There has been some disscussion around the office lately about where exactly SQLCMD.EXE comes from and if it's redistributeable. I have yet to find any good answers for that, but perhaps "Support Files" is where this useful command line utility resides. I wonder if you need a license to install the prerequisites? Hummm. More on this later when we start talking about deploying database objects.<br /></p><p>I'm running into an odd thing. The MSDN DVD that I have from MS that says it has ISOs of all the various SQL 2005 installations does not have an ISO for the enterprise edition. It has a set of folders directly on the DVD. That's extremely inconvenient because I'm installing to a Virtual Machine. So I have to copy down a huge folder of installation packages to my VM to run the install and later delete. Thanks guys. And don't even think about exposing your DVD drive via Remote Desktop – you can't do installs that way (a good thing). ISOs are indicated here, file folders are "so last week".<br /></p><p>Well, to answer the question about SQLCMD.EXE, it is definitely not installed with the "Support Files". I searched my HD after installing the prerequisites and it's not there. Bummer.<br /></p><p>The System Configuration Check is the next setup dialog and it gave me two warnings:<br /></p><p><span style="font-family:Microsoft Sans Serif; font-size:8pt"><strong>- Minimum Hardware Requirement (Warning)</strong><br /> </span></p><p style="margin-left: 40pt"><span style="font-family:Microsoft Sans Serif; font-size:8pt"><strong>Messages</strong><br /> </span></p><ul style="margin-left: 40pt"><li><span style="font-family:Microsoft Sans Serif; font-size:8pt">Minimum Hardware Requirement<br/><br /> </span></li></ul><p><span style="font-family:Microsoft Sans Serif; font-size:8pt">The current system does not meet the minimum hardware requirements for this SQL Server release. For detailed hardware and software requirements, see the readme file or SQL Server Books Online.<br /></span></p><p><span style="font-family:Microsoft Sans Serif; font-size:8pt"><br/><strong>- IIS Feature Requirement (Warning)</strong><br /> </span></p><p style="margin-left: 40pt"><span style="font-family:Microsoft Sans Serif; font-size:8pt"><strong>Messages</strong><br /> </span></p><ul style="margin-left: 40pt"><li><span style="font-family:Microsoft Sans Serif; font-size:8pt">IIS Feature Requirement<br/><br /> </span></li></ul><p><span style="font-family:Microsoft Sans Serif; font-size:8pt">Microsoft Internet Information Services (IIS) is either not installed or is disabled. IIS is required by some SQL Server features. Without IIS, some SQL Server features will not be available for installation. To install all SQL Server features, install IIS from Add or Remove Programs in Control Panel or enable the IIS service through the Control Panel if it is already installed, and then run SQL Server Setup again. For a list of features that depend on IIS, see Features Supported by Editions of SQL Server in Books Online.<br /></span></p><p><span style="font-family:Microsoft Sans Serif; font-size:8pt"><br/></span>The first is prolly talking about my memory footprint. I only gave this VM 512MB RAM, so I'll restart it with 1 full 1GB and see if that helps. The second is telling me I should add the IIS application role to this machine if I would like to add all the Web Service hooks. I do, but it's nice to see that it's not a requirement. Sometimes a database should just be a database.<br /></p><p>Installing IIS is as easy as adding an Application Server Role to the server using the Management Interface. It will squawk for the "Service Pack 1" CD, but it's really talking about the Windows Server 2003 R2 Disk 1, so I load that ISO into the CD of the Virtual Machine. Lucky for me, I have it lying around in my c:\vmroot folder on the Virtual Server, so no file moving is required. I checked the boxes for Front Page Extensions and Install ASP.Net because I don't know any better. I'm hoping that Front Page Extensions are not used, but you never know. In a production environment, I'd avoid FPE.<br /></p><p>Unfortunately I have to shut down the VM to change the RAM size. The next version of Virtual Server should let you change this on the fly.<br /></p><p>With IIS added to this VM, and double the RAM, I'm ready to try again. I notice that I completely read the whole "Support Files" thing wrong. Those are "Setup Support Files" so just ignore me on that tangent. The System Configuration Check is all green lights and I'm on to installing components. I select everything: Database Services, Analysis Services, Reporting Services, Notification Services, Integration Services and workstation components. I actually plan to run the workstation components from a client machine, but I'll put them here anyway. I'm selecting the built-in service account of "Local System" to run my Default Instance rather than a Domain Account just to keep things simple. I'm selecting Windows Authentication only mode for my server. SQL Logins give me the heebee-jeebees. Everything else is pretty standard. This install is a long one so this post will be in two parts…</p></span><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35892304-116063997732012076?l=sqlclr.blogspot.com'/></div>nohorsehttp://www.blogger.com/profile/05236079390128087517noreply@blogger.com0tag:blogger.com,1999:blog-35892304.post-1160634707585331832006-10-11T23:31:00.000-07:002006-10-17T00:14:48.476-07:00VM Tip #1 Build a Base VHD<span xmlns=""><p>The Longest most painful part of setting up a VM is installing the operating system. You only want to do this once, and then save that base VHD somewhere. If you really want that OS install to take for-ev-er , then use the SCSI channel. Hours. I like SCSI VMs because I think they are a little faster, but not for doing the initial install. Use the regular IDE channel for that. Then once you get the OS installed (plus virtual machine additions) add a SCSI adapter and then move the Hard Disk to the SCSI channel. When you restart the VM things should be cool. Now make a copy of the VHD before you go installing anything else on there.<br /></p><p>Well, there might be one thing you will want to do to that base install, and that remove the 2003 shutdown "Nag Screen". You know the one where you are forced to type a few characters into the comment box. Ya. Start->Run->gpedit.msc->Administrative Templates->System->Display Shutdown Event Tracker->Disabled.<br /></p><p>And you want to get away from the built-in Virtual Server ActiveX Remote Control ASAP. So It's a good idea to change the Remote Settings on the System Properties to Enable Remote Desktop.<br /></p><p>And you could even save yourself a little future headache by installing your first 47 Critical Updates. But that's it. No office, no IDE, no Firefox or even your favorite utility. Just stop now and you'll thank yourself later.</p></span><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35892304-116063470758533183?l=sqlclr.blogspot.com'/></div>nohorsehttp://www.blogger.com/profile/05236079390128087517noreply@blogger.com0tag:blogger.com,1999:blog-35892304.post-1160631548837540162006-10-11T22:39:00.000-07:002006-10-11T22:39:08.843-07:00Better late than Never<span xmlns=""><p>I'm finally setting up my lab to do my SQL2005 investigations. I'm blogging from my glass cube running the Vista Beta, remote desktopping into the virtual server and creating some virtual machines. I think all the layers of remoting are making the mouse not work correctly on the DOS install for windows 2003 R2 where I'll be installing SQL 2005. Let's see Vista->Remote Desktop->Virtual Server->ActiveX Remote Control->DOS… ya. No problem.<br /></p><p>This time, when I'm setting up my Virtual Machines I'm going to take a tip from my buddy John and create a root folder for all my images. D:\vmroot will be where all the ISOs and VHDs live. This will save me digging into the c:\Documents and Settings\All Users\Shared Documents\Shared Virtual Machines tree. I can also save myself some cutting and pasting by adding d:\vmroot to the "Search Paths" on Virtual Server. Good thing it took me 6 months of using Virtual Server to figure that out. From the virtual server admin web site select "Server Properties" from the navigation panel and then "Search Paths". This make whatever is in that path show up on all the ISO and VHD selection dropdowns. Very nice.<br /></p><p>BTW, I'm using the new Word2007 Blog Posting feature to auth-publish to a Blogger site. It's pretty slick one you figure it out. I think the trick is you have to have an outlook account configured to send email from. I got some cryptic error messages about not being able to set up a blogging provider, then everything magically started working when I added an email account to outlook. No way to verify, but if your having trouble posting to your blog from Word 2007, try that. Including pictures has always been an issue with blogger, and this wordblog stuff does not make that any easier. If I get inspired, I'll try and make the picture thing work, but until then it's just text. Now if I can Blog from OneNote….Now we are talking.<br /></p><p>Anyway, back to SQL and the CLR: I'm running thru "A developer's guide to SQL Server 2005" chapter by chapter and blogging all the way. I'm starting off with a fresh install of SQL 2005 Enterprise Edition running in a Virtual Machine of Windows 2003 R2. I'll be using Vista and 2003R2 for my client tools.</p></span><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35892304-116063154883754016?l=sqlclr.blogspot.com'/></div>nohorsehttp://www.blogger.com/profile/05236079390128087517noreply@blogger.com0tag:blogger.com,1999:blog-35892304.post-1160628749725891312006-10-11T21:52:00.000-07:002006-10-11T21:52:29.756-07:00oneone<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/35892304-116062874972589131?l=sqlclr.blogspot.com'/></div>nohorsehttp://www.blogger.com/profile/05236079390128087517noreply@blogger.com0