08 January 2008

How do I install the AdventureWorks sample database with SQL Server 2005 Express?

File Download:

  1. Navigate to: http://www.codeplex.com/MSFTDBProdSamples.
  2. From the: Releases tab, click: SQL Server 2005 (hyperlink).
  3. Scroll down and click: AdventureWorksLT.msi.
  4. Save the file to your desktop or other known location.
  5. Once the download is complete, click: Run (or navigate to the location where you saved the file and double-click: AdventureWorksLT.msi) to start the install.
  6. Follow the prompts (using the default selections) to complete the install.

DB Permissions Configuration:

  1. From the keyboard, press: Windows Key + E to launch Windows Explorer.
  2. In Windows Explorer, navigate to: C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data.
  3. Right-click: AdventureWorksLT_Data.mdf then select: Properties.
  4. Click: Security > Edit > Add.
  5. Type your login name into the: Enter the object names... textbox then click: Check Names. Your entry will automatically resolve to: MACHINENAME\Login.
  6. Click: OK.
  7. Select your login name from the: Groups or usernames list.
  8. In the: Permissions for LoginName box, click: Full control then click: OK > OK. You should now be back at the Windows Explorer window.
  9. Right-click: AdventureWorksLT_Log.ldf then repeat this process to change the user permissions for that file as well.

SQL Server Management Studio Configuration:

  1. Launch Microsoft SQL Server Management Studio Express and connect to your local server. Ensure that the default connection settings are used.
  2. From Object Explorer, right-click: Databases then click: Attach. The: Attach Databases dialog will appear.
  3. Click: Add.
  4. Click: AdventureWorksLT_Data.mdf then click: OK.
  5. Click: OK. You should now be at the main window for: Microsoft SQL Server Management Studio Express.
  6. In Object Explorer, expand: Databases > AdventureWorksLT > Tables.
  7. Right-click: dbo.BuildVersion then select: Script Table as > SELECT to > New Query Editor Window.
  8. Press: F5. The query will return the build version, confirming a successful installation.

Possible Problems:

Error: The database 'AdventureWorks' cannot be opened because it is version 631. This server supports version 612 and earlier. A downgrade path is not supported. Could not open new database...

Error: Error 27506. Error executing SQL script sqlscript.sql. Line 17. The database 'AdventureWorksLT' cannot be opened because it is version 631. This server supports version 612 and earlier. A downgrade path is not supported (948)...

These errors are generated when you attempt to install AdventureWorks for SQL Server 2008 on SQL Server 2005. The CodePlex website contains two versions of the database: One for SQL Server 2005 and one for SQL Server 2008. Repeat the: File Download: portion of this tutorial and be sure to click the SQL Server 2005 hyperlink.

Error: Error 1722.There is a problem with this Windows Installer package. A program run as part of the setup did not finish as expected. Contact your support personnel...

This error is also generated after attempting to install AdventureWorks for SQL Server 2008 on SQL Server 2005, though this error code may be specific to a Windows XP installation. Either way, repeat the: File Download: portion of this tutorial and be sure to click the SQL Server 2005 hyperlink.

Error: CREATE File encountered operating system error 5(access denied) while attempting to open/create the file.... MS SQL error 5123...

This error (or similar) is related to file permissions for: AdventureWorksLT_Data.mdf and/or AdventureWorksLT_Log.ldf. In either case, repeat the: DB Permissions Configuration: portion of this tutorial.

How do I minimize iTunes to the Task Bar?

To send iTunes to the Windows Task Bar when minimized:

  1. From the desktop, right-click on an empty portion of the Task Bar then select Properties.
  2. Select the Toolbars tab then enable the iTunes toolbar.
  3. Click: OK. With this option enabled, iTunes will minimize to the Task Bar (near the notification area).

How do I prevent a program from starting when Windows boots?

Method 1

  1. Select: Start > All Programs > Startup.
  2. Locate the desired program then right-click on the name and select Delete. Note: This will not delete the actual program, it simply removes it from the Startup folder.
  3. Restart your computer.

If the program is not listed in the Startup folder...

Method 2

  1. Click: Start then type: system.
  2. Click: System Configuration in the Programs list.
  3. From the Startup tab, disable the desired program by removing it's check from the Startup Item column. Note: Take care when disabling items in the System Configuration window. Some of these items may be required for proper system function.
  4. Restart your computer.

If you are still unable to locate the desired program:

Method 3

  1. Try AutoRuns.

How do I organize and import my music library into iTunes (v7.5)?

  1. To avoid confusion, close or minimize all open applications.
  2. Open 1 Windows Explorer window by pressing: Windows Key + E.
  3. Navigate to the directory containing your existing music library.
  4. Launch iTunes.
  5. From the iTunes menu bar, select: Edit > Preferences > Advanced > General.
  6. Enable the options titled: Keep iTunes Music folder organized and: Copy files to iTunes Music folder when adding to library.
  7. Click: OK. The first option (Keep iTunes Music...) provides the organized folder structure and file naming, while the second option (Copy files to...) creates a copy in the default iTunes Music directory (mine is: C:\Users\AbleBaker\Music\iTunes\iTunes Music).
  8. Return to your Windows explorer session and begin to drag-and-drop your music files / folders into the iTunes player. Unless you intend to leave your computer alone for a few minutes is a good idea to transfer a relatively small number of files / folders at each pass as it may slow the system considerably.
  9. Your library is now organized and imported. Since the files were actually copied into the iTunes folder, you could safely choose to delete your old music directory.

06 January 2008

How do I select the name for a day of the week?

Selecting the name for a day of the week is fairly straight forward using the DATENAME function and a DATEPART argument. For example:

SELECT DATENAME(weekday, GETDATE()) AS 'MyDay';
returns:

MyDay
------
Sunday

We could also use DATENAME to obtain the name of a month:

SELECT DATENAME(month, GETDATE()) AS 'MyMonth';
Which returns:

MyDay
-------
January

For additional information, please visit: http://msdn2.microsoft.com/en-us/library/ms174395.aspx

How do I select only the date from a datetime data type?

Selecting only the date portion from a datetime data type could be accomplished in a number of ways. One of the most convenient methods is to simply use CONVERT and one of the many style values.

SELECT GETDATE() AS MyDate
returns the default format:

MyDate
-----------------------
2008-01-06 19:39:15.410

However, buy using CONVERT and applying a particular style value, we are able to achieve the desired result. For example:

SELECT CONVERT(VARCHAR(10),GETDATE(),126) AS MyDate
returns:

MyDate
----------
2008-01-06

Another style example:

SELECT CONVERT(VARCHAR(10),GETDATE(),101) AS MyDate
returns:

MyDate
----------
01/06/2008

For additional information, visit: http://msdn2.microsoft.com/en-us/library/aa226054(SQL.80).aspx