Archive for the ‘ Tutorials ’ Category

Resizing your VMWare Disk in 12 Steps

Every now and then I need to resize my VMWare Server disks.

The is the easiest and least troublesome way, from my experience, is to use GParted Live (Gnome Partition Editor)

Prep Work:

1. Download GParted (Gnome Partition Editor) Live (http://sourceforge.net/projects/gparted/files/gparted-live-stable/). It is an iso file that we will mount to our vm

2. Locate where your vmware-vdiskmanager.exe is. It would typically reside in the install folder, for example:

 C:\Program Files (x86)\VMware\VMware Server\vmware-vdiskmanager.exe

3. Note the path to your virtual disk (vmdk). For example:

 vmware-vdiskmanager.exe -x 20GB "C:\Virtual Machines\SQL2005SP3\
  Windows Server 2003 Enterprise Edition\Windows Server 2003 Enterprise Edition.vmdk"

Ready to resize your VMWare disk? Let’s go:

1. Shut down your VM
2. Open the Command Prompt
3. Go to the folder where you have your vmware-vdiskmanager.exe is (or if you have added this to your PATH, then it doesn’t matter from which path you execute it from).

 cd C:\Program Files (x86)\VMware\VMware Server

4. Resize your disk. For example if you want to resize your disk from 10GB to 20GB:

 vmware-vdiskmanager.exe -x 20GB "C:\Virtual Machines\SQL2005SP3\
  Windows Server 2003 Enterprise Edition\Windows Server 2003 Enterprise Edition.vmdk"

5. Confirm that your VM disk size has been changed, before we resize your partition

  1. Power up your VM
  2. Go to Administrative Tools > Computer Management > Disk Management
  3. Check how much space you have in your disk. You should see an extra 10GB unallocated

6. Shut down your VM again.

7. In your VMWare web access, select your VM.

8. Mount the GParted Live ISO

  1. In the Hardware section, select “CD/DVD Drive”
  2. Select the dropdown arrow, then click Edit
  3. In the Window that appears, select Host Media, and under Connection section select ISO image. Navigate to the GParted Live ISO location, and then save your preferences.

9. Configure your VM to boot from CD/DVD

  1. Configure VM on the right hand panel
  2. In the popup window that appears, go to the Power tab.
  3. Go to the BIOS Setup section, and check “Enter the BIOS setup screen the next time this virtual machine boots” and save your preferences.

10. Restart your VM

11. Resize your partition using GPartLive

  1. Follow the screens, and select appropriate options if prompted (i usually select defaults) ex:
    language           US English
    keyboard          qwerty/us.map
    video driver    generic
    resolution        1024X768
  2. When the partition editor appears, you will see a partition named /dev/sda1
  3. Click on Resize/Move button above the partition list
  4. The /dev/sda1 becomes a movable slider. Drag the slider (make sure it’s double arrow, not four way arrow) all the way to the end of the partition. The double arrow is a “resize” operation, while the four way arrow is a “move” operation.
  5. When done, click Apply.
  6. When resize operation is complete, click Close.
  7. Click the “Power” button, and choose to reboot.

12. When your VM starts up, it will prompt you to do a checkdisk. Let this finish. You will be prompted to reboot (yet again). Reboot – do not resist :)

Last Check

Now, when your VM starts up again, check your disk to confirm additional space has been allocated:

  1. a. Go to Administrative Tools > Computer Management > Disk Management
  2. b. Check your Primary Partion. Check that the new size is correct, and that there is no unallocated space

That’s it, we’re done.

VN:F [1.4.0_681]
Rating: 10.0/10 (6 votes cast)
Share :
  • Digg
  • del.icio.us
  • Google
  • description
  • StumbleUpon
  • Technorati
  • TwitThis

Step by Step Guide to Creating a SQL Server VM Using VMWare

Download PDF file

I typically use SQL Server VMs for my development and administration classes. I want the students to have full autonomy over the machines they are using, so that they can try out different features and configurations without worrying about wrecking a whole lab machine.

This tutorial steps the students through how to create and configure their own standalone SQL Server VMs. We will be using:

· VMWare Server

· Windows Server 2008

· SQL Server 2008

Terms

A few terms to familiarize yourselves with before we start:

Virtual Machine (VM) This is essentially a standalone computer installed within another platform/OS.

A virtual machine is also sometimes called a guest machine. This typically provides a complete system platform with its own set of operating system, hardware configurations, and installed software packages, but still runs on top of a “host” machine which has the main OS, and the physical hardware.

There are different applications that can create and run virtual machines:

VMware Server
MS Virtual Server

MS Virtual PC

Virtual Box

ISO file This is a disk image, an archive file of an optical disc in a format defined by the International Organization for Standardization (ISO). This contains archived CD/DVD content, and you can point your VM to an ISO file to read or use the content.

You can create ISO files using any CD/DVD image file processing tool, like:

PowerISO

MagicISO

FreeISO Creator
Nero Burning Software

Prep Work

1. Download and install VMWare Server (http://www.vmware.com/products/server/)

You will need to register, and get the serial number for your free VMWare Server. Once it’s installed, you should have a link to VMWare Server Home Page from your Start > Programs menu.

clip_image002

2. Get your media for :

· your operating system (ex Windows Server 2008)

· SQL Server (up to you which version you want to install)

or better yet, or if you have MSDN/MSDNAA/Technet Subscriptions, download it from the Microsoft Site. If there is an option to download an .iso file, download the .iso file. Otherwise you will need to create this yourself later.

Read the rest of this entry »

VN:F [1.4.0_681]
Rating: 10.0/10 (5 votes cast)
Share :
  • Digg
  • del.icio.us
  • Google
  • description
  • StumbleUpon
  • Technorati
  • TwitThis

To view your SQL Server (or SSRS) reports using PowerShell, you can either use

  • plain browser + URL string combo
  • Report Viewer
  • Web Services

The script below shows the first two options.
If you are going to go with Report Viewer (and personally, that’s my preference), you will need to download the ReportViewer redistributable package

One of these days I will hammer through the Web Services option, and also play more with what can be done with Report Viewer. And when I have good demos, I definitely will post them here :)

#==============================================================
#VANPASS August 2009
#PowerShell and SSRS (SQL Server Reporting Services)
#Donabel Santos
#http://www.sqlmusings.com / http://www.twitter.com/sqlbelle
#==============================================================
 
#--------------------------------------------------------------
#Approach 1: simplistic approach - accessing report via URL
#--------------------------------------------------------------
Set-Alias ie "$env:programfiles\Internet Explorer\iexplore.exe"
 
#note you can control how the report is rendered via the parameters in the URL string
ie "http://localhost/ReportServer/Pages/ReportViewer.aspx?%2fReports%2fSample+Report&rs:Command=Render"
 
 
#--------------------------------------------------------------
#Approach 2: using the ReportViewer
#You need to download the ReportViewer redistributable package
#--------------------------------------------------------------
#I am qualifying this because I have more than one version in my system
#If you need webforms, use Microsoft.ReportViewer.WebForms
[void] [System.Reflection.Assembly]::Load("Microsoft.ReportViewer.WinForms, `
	Version=9.0.0.0, Culture=neutral, `
	PublicKeyToken=b03f5f7f11d50a3a")
 
#Windows.Forms for viewing dialog box
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
 
#System.IO because I want to export to Excel
[void][System.Reflection.Assembly]::LoadWithPartialName("System.IO")
 
#System.IO because I want to open Acrobat
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Diagnostics")
 
#for credentials, if needed
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Net")
 
$rv = New-Object Microsoft.Reporting.WinForms.ReportViewer;
$rv.ProcessingMode = "Remote";
$rv.ServerReport.ReportServerUrl = "http://localhost/reportserver";
$rv.ServerReport.ReportPath = "/Reports/Sample Report";
 
#if you need to provide basic credentials, use the following
#$rv.ServerReport.ReportServerCredentials.NetworkCredentials= 
#	New-Object System.Net.NetworkCredential("myuser", "mypassword");
 
$rv.Height = 600;
$rv.Width = 800;
$rv.RefreshReport();
 
#--------------------------------------------------------------
#Show as Dialog Using Windows Form
#--------------------------------------------------------------
#create a new form
$form = New-Object Windows.Forms.Form;
 
#we're going to make it just slightly bigger than 
$form.Height = 610;
$form.Width= 810;
$form.Controls.Add($rv);
$rv.Show();
$form.ShowDialog();
 
#--------------------------------------------------------------
#Export to Excel
#--------------------------------------------------------------
#now let's try exporting to Excel
$mimeType = $null;
$encoding = $null;
$extension = $null;
$streamids = $null;
$warnings = $null;
 
$bytes = $rv.ServerReport.Render("Excel", $null, 
                                [ref] $mimeType, 
                                [ref] $encoding, 
				[ref] $extension, 
				[ref] $streamids, 
				[ref] $warnings);
$file = "C:\VANPASS\samplereport.xls";
$fileStream = New-Object System.IO.FileStream($file, 
              [System.IO.FileMode]::OpenOrCreate);
$fileStream.Write($bytes, 0, $bytes.Length);
$fileStream.Close();
 
#let's open up our excel application
$excel = New-Object -comObject Excel.Application
$excel.visible = $true;
$excel.Workbooks.Open($file) | Out-Null;
 
#--------------------------------------------------------------
#Export to PDF
#--------------------------------------------------------------
$bytes = $rv.ServerReport.Render("PDF", $null, 
                                [ref] $mimeType, 
                                [ref] $encoding, 
				[ref] $extension, 
				[ref] $streamids, 
				[ref] $warnings);
$file2 = "C:\VANPASS\samplereport.pdf";
$fileStream = New-Object System.IO.FileStream($file2, 
             [System.IO.FileMode]::OpenOrCreate);
$fileStream.Write($bytes, 0, $bytes.Length);
$fileStream.Close();
[System.Diagnostics.Process]::Start($file2)
 
 
#--------------------------------------------------------------
#Other ways to render or access your reports:
#SSRS Web Services
#--------------------------------------------------------------
VN:F [1.4.0_681]
Rating: 10.0/10 (9 votes cast)
Share :
  • Digg
  • del.icio.us
  • Google
  • description
  • StumbleUpon
  • Technorati
  • TwitThis

VANPASS Presentation and Demo Files on SQL Server and PowerShell

I did a presentation today for VANPASS on PowerShell and SQL Server – thank you to those who attended! It was a great lively crowd :) Thanks to Idera too – for the freebies – and to Black Ninja Software for the pizza and pop!

Here are the files as promised: VANPASS – SQL Server and PowerShell – Donabel Santos

The zipped file contains the presentation and all of the samples (ones that I demo’d, and ones I didn’t have time to demo). The demos are:

  • Demo 01 – Common PowerShell Tasks – Complete.PS1
  • Demo 02 – PowerShell Basics – Complete.PS1
  • Demo 03a – SQL Server 2008 Mini Shell – Complete.PS1
  • Demo 03b – Server and Database Properties.PS1
  • Demo 03c – SQL Server Services and Jobs.PS1
  • Demo 03d – Scripting SQL Server Objects.PS1
  • Demo 03e – Searching for Objects.PS1
  • Demo 03f – Basic DDL and DML Import.PS1
  • Demo 03f – Basic DML.PS1
  • Demo 03g – Backup and Restore.PS1
  • Demo 04 – SQL Server PSX – Complete.PS1
  • Demo 05 – SQL Server PSSnapin – Complete.PS1
  • Demo – SSIS.PS1
  • Demo – SSRS.PS1
  • Out-Report from Chad Miller

I have used a lot of resources when I was creating all these samples, and I have tried to enumerate them in my presentation. And I also just realized I had a lot of samples and was only able to get through 2/3 of them.

I enjoy presenting at VANPASS, it is always a great crowd. Please feel free to drop me a line, or comment on my blog, or message me on twitter(sqlbelle) – if you have other SQL Server PowerShell questions, or if you had questions at the presentation that I wasn’t able to address.

Thanks to Richard Baumet and Scott Stauffer for inviting me to speak.
And thanks to Idera too – I love using your PowerShell Plus!

VN:F [1.4.0_681]
Rating: 9.8/10 (5 votes cast)
Share :
  • Digg
  • del.icio.us
  • Google
  • description
  • StumbleUpon
  • Technorati
  • TwitThis

Free PowerShell Ebook (Mastering PowerShell) from PowerShell.com

If you have the slightest interest in PowerShell, and you’re keen on learning more about it, I strongly recommend you download this book:

Mastering PowerShell (from PowerShell.com and written by Dr. Tobias Weltner)

It is an awesome, well written 567 page book that covers PowerShell through and through. Here are the chapters:

  1. The PowerShell Console
  2. Interactive PowerShell
  3. Variables
  4. Arrays and Hashtables
  5. The PowerShell Pipeline
  6. Using Objects
  7. Conditions
  8. Loops
  9. Functions
  10. Scripts
  11. Finding and Avoiding Errors
  12. Command Discovery and Scriptblocks
  13. Text and Regular Expressions
  14. XML
  15. The File System
  16. The Registry
  17. Processes, Services, Event Logs
  18. Windows Management Instrumentation
  19. User Management
  20. Your Own Cmdlets and Extensions

Thanks PowerShell.com!

VN:F [1.4.0_681]
Rating: 10.0/10 (2 votes cast)
Share :
  • Digg
  • del.icio.us
  • Google
  • description
  • StumbleUpon
  • Technorati
  • TwitThis

SQLXML : How to Work With XML Elements (or Nodes) in SQL Server

Assume this is your XML snippet


DECLARE @authorsXML XML

SET @authorsXML = '
<Author>
  <ID>172-32-1176</ID>
  <LastName>White</LastName>
  <FirstName>Johnson</FirstName>
  <Address>
    <Street>10932 Bigge Rd.</Street>
    <City>Menlo Park</City>
    <State>CA</State>
  </Address>
</Author>
'

Note that the examples below show how you can manipulate XML nodes – but most operations require singleton values. Ie, the changes must affect one and only one node. Thus in most the examples we specify the index of the node we want to target.

For example:


(/Author/LastName)[1]

which means we are only targetting the first instance of LastName under the Author node. If you need to do a mass update, you may need to use a cursor.

Read the rest of this entry »

VN:F [1.4.0_681]
Rating: 9.3/10 (12 votes cast)
Share :
  • Digg
  • del.icio.us
  • Google
  • description
  • StumbleUpon
  • Technorati
  • TwitThis

Soaking in SQLServerPedia

One of the bloggers I follow is Brent Ozar. I tell you I’m a fan. I like the way he writes his stuff.

Anyway, he blogged about The Problem With SQL Server Training Today, and The Answer to SQL Server Training Problems a week or so ago. And this is the answer – SQLServerPedia  – SQL Server Knowledge and Advice Straight from the Experts.

So in between giving out candies to cute little Indiana Joneses, pirates of the Caribbean, vampires and dead cheerleaders, I’ve been soaking in SQLServerPedia (geeky ‘no?). So far, so good. I’ll be a frequent flyer.

 

PS – and if you’re a DBA, you’ll find great laughs in this post : Somebody Created a Halloween Monster #SQLputdowns

VN:F [1.4.0_681]
Rating: 0.0/10 (0 votes cast)
Share :
  • Digg
  • del.icio.us
  • Google
  • description
  • StumbleUpon
  • Technorati
  • TwitThis

SQL Server 2008 Jumpstart and other resources

Just a short compilation of SQL Server 2008 resources (white papers, ebooks, videos, blogs)

Blog Posts

Upgrading to SQL Server 2008
http://glennberrysqlperformance.spaces.live.com/Blog/cns!45041418ECCAA960!1019.entry

10 Reasons Why SQL Server 2008 Is Going to Rock
http://angryhacker.com/blog/archive/2008/06/20/10-reasons-why-sql-server-2008-is-going-to-rock.aspx

The SQL Server 2008 Status Bar Custom Colors (why it’s not trivial!)
http://blog.jemm.net/2008/08/12/sql-server-2008-management-studio-tip-status-bar-custom-colors/

Notification Services Support in SQL Server 2008 :)
http://weblogs.sqlteam.com/joew/archive/2008/09/10/60708.aspx

Additional MS Training/Resources

SQL Server 2008 Jumpstart
http://sqlserver2008jumpstart.microsofttraining.com

Microsoft SQL Server 2008 – Learning Portal
http://www.microsoft.com/learning/sql/2008/default.mspx

Free SQL Server 2008 Ebook from MS Press
http://csna01.libredigital.com/?urss1q2we6

SQL Server 2008 Videos
http://go.microsoft.com/?linkid=9333556

SQL Server 2008 Virtual Labs
http://www.microsoft.com/sqlserver/2008/en/us/virtual-labs.aspx

Webcasts: 24 Hours of SQL Server 2008 for IT Professionals
http://go.microsoft.com/?linkid=9333557

Webcasts: 24 Hours of SQL Server 2008 for Developers
http://go.microsoft.com/?linkid=9333558

VN:F [1.4.0_681]
Rating: 0.0/10 (0 votes cast)
Share :
  • Digg
  • del.icio.us
  • Google
  • description
  • StumbleUpon
  • Technorati
  • TwitThis
`