Archive for October 11th, 2008

Clustering SQL Server 2005 Videos … and some hacking

Brian Knight has posted a lot of good videos on JumpStartTV, including the following clustering videos:

  • Windows and SQL Server 2005 Clustering Architecture  (16:14)
    http://www.jumpstarttv.com/windows-and-sql-server-2005-clustering-architecture_31.aspx
  • Clustering Windows 2003 R2  (13:26)
    http://www.jumpstarttv.com/clustering-windows-2003-r2_32.aspx
  • Clustering SQL Server 2005  (16:21)
    http://www.jumpstarttv.com/clustering-sql-server-2005_33.aspx

Plus one video on how to hack (read: SQL Injection), and prevent hacking, SQL Server:

  • Hacking SQL Server   (55:59)
    http://www.jumpstarttv.com/hacking-sql-server_76.aspx

These are good videos, some of them almost an hour long like the Hacking video, most in the 5-15 minute duration. What’s also good about the site is  on the sidebar, the “pre-requisite” videos are mentioned.

JumpStartTV also has videos on Administration, High Availability, Performance Tuning, SMO, Data Warehousing and SSIS (Brian Knight made a whole bunch on SSIS), to name a few.

The videos are free, but JumpStartTV requires registration.

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Error:

Attribute-centric column ‘@Title’ must not come after a  non-attribute-centric sibling in XML hierarchy in FOR XML PATH.

Reason:

You are having this issue if you have attribute- and element-centric columns in your FOR XML PATH query that are interleaved, as such:

SELECT
    EmployeeID       AS '@EmployeeID',            -- attribute
    FirstName        AS 'Details/FirstName',      -- nested element
    LastName         AS 'Details/LastName',       -- nested element
    Title            AS '@Title'                  -- attribute
FROM
    dbo.Employee
FOR XML PATH('Employee')

Resolution:

Order of attribute-centric columns in your FOR XML PATH query matters … if you have nested elements.

To resolve the error above, you must specify all attributes first, then specify the nested elements

SELECT
    EmployeeID       AS '@EmployeeID',            -- attribute
    Title            AS '@Title',                 -- attribute
    FirstName        AS 'Details/FirstName',      -- nested element
    LastName         AS 'Details/LastName'        -- nested element
FROM
    dbo.Employee
FOR XML PATH('Employee')

/*
Sample Output:
 
<Employee EmployeeID="1" Title="Production Technician - WC60">
  <Details>
    <FirstName>Guy</FirstName>
    <LastName>Gilbert</LastName>
  </Details>
</Employee>
*/

VN:F [1.9.22_1171]
Rating: 1.0/10 (1 vote cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

White Papers: Backup/Recovery, Performance Tuning

Here are some older Quest White Papers (specific to SQL Server 2000, but general concepts and practices still applicable to SQL Server 2005/2008):

 

Backup/Recovery

SQL Server Backup Recovery & Troubleshooting. Part 1
SQL Server Backup Recovery & Troubleshooting. Part 2

 

Performance Tuning

Part 1: Analyzing and Optimizing T-SQL Query Performance on MS SQL Server using SET and DBCC
Part 2: Index Tuning Strategies
Part 3: Query Optimization Strategies
Part 4. Analyzing and Optimizing T-SQL Query Performance on Microsoft SQL Server using SHOWPLAN Output and Analysis

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Been a while since I blogged on SharePoint. For the past year I have been more involved in DBA work, and have been more active in my other blog (http://sqlmusings.wordpress.com)

Anyway, here is an old script I have been meaning to post:

#* FileName:  PowerShellTemplate.ps1
#*=============================================================================
#* Created:     [11 December 2007]
#* Author:      Donabel Santos
#* Reqrmnts:   
#* Keywords:   
#*=============================================================================
#* Purpose:    
#*             
#* This Powershell script queries ActiveDirectory for OU-specific
#* users and inserts those users as new records in a Sharepoint
#* out-of-the-box Contact List
#*=============================================================================
#*=============================================================================
#* SCRIPT BODY
#*=============================================================================
#Powershell Script that queries a specific OU in AD,
#and populates the Contact List
#based on the members that are queried
#IMPORTANT NOTE:
#This needs to be run on the MOSS Server because the
#SP Object Model cannot be invoked remotely
#Step 1: Install Powershell RC2
#http://support.microsoft.com/kb/925228
#Step 2: Set Execution Policy to RemoteSigned (uncomment below)
#Set-ExecutionPolicy RemoteSigned
#Step 3: Set the following variables
$siteUrl = "http://moss/sites/test"
$ou = "LDAP://OU=My Group,OU=Guest Users,DC=domain,DC=ca"
#Step 4: Run this script on Powershell on the Sharepoint Server
#Rest of code follows
#Load Sharepoint DLL
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
#we want to query just the top web of the "test" site collection
$webName = ""
#create a site object
$spSite = new-object Microsoft.SharePoint.SPSite($siteurl)
#the following just displays URL, ID, Name and Users in a table format
$spSite.AllWebs | format-table Url, ID, Name, AllUsers
#open web
$spWeb = $spSite.OpenWeb($webName)
#we want to get a handle on contacts
$listName = "Contacts"
#get a handle to the Contacts list
$spList = $spWeb.lists[$listName]
#Create an AD DirectorySearcher object
$searcher = new-object DirectoryServices.DirectorySearcher([ADSI]"$ou")
#sample filter below, if you need to filter further
#$searcher.filter = "(&(objectClass=user)(givenName=Belle))"
#find all that matches
$groups = $searcher.findall()
#the following for loop just displays
@(foreach($group in $groups)
{
    [string]$firstname = $group.properties.givenname
    [string]$lastname = $group.properties.sn
    if (($firstname.length -gt 0) -and ($lastname.length -gt 0))
    {
       "Given Name:{0} {1}" -f  $firstname, $firstname.length
    }
}
)
#this code block inserts the AD user as a new user 
#into the Sharepoint Contact list
@(foreach($group in $groups)
{
    #extract all properties we need first
    #add fields here if necessary
    [string]$name = $group.properties.name
    [string]$firstname = $group.properties.givenname
    [string]$lastname = $group.properties.sn
    [string]$company = $group.properties.company
    [string]$email = $group.properties.mail
    [string]$objectclass = $group.properties.objectclass
    [string]$distinguishedname = $group.properties.distinguishedname
    #now add this to the sharepoint list only if first name 
    #and last name are not empty
    #add fields here if necessary
    if (($firstname.length -gt 0) -and ($lastname.length -gt 0))
    {
       $spitem = $spList.Items.Add()
       $spitem["Last Name"] = $lastname
       $spitem["First Name"] = $firstname
       $spitem["Company"] = $company
       $spitem["E-mail Address"] = $email
       $spitem.Update()
    }
}
)
#voila! we're done!
#*=============================================================================
#* END OF SCRIPT: 
#*=============================================================================
VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Fixing Collation: The Experiments

We’re trying to solve a few collation issues we have been having, and I had collation overload this week.

The Scenario
•    Some of our SQL Server instanced were installed using the default collation SQL_Latin1_General_CP1_CI_AS
•    We need to have case insensitive, accent insensitive – Latin1_General_CI_AI
•    We changed some of our database collations to Latin1_General_CI_AI

The Problems

•    We want to change the model database’s collation, so that all new databases get the collation we want
•    We want to change the tempdb collation, so that all temporary objects don’t have to use explicit collation

We use temporary tables in some of our important stored procedures and UDFs. It will be an issue if we have different collations between our user databases and tempdb. Yup, trying to do a query that involved these two tables will result in an error similar to:

Cannot resolve the collation conflict between “Latin1_General_CI_AI” and “SQL_Latin1_General_CP1_CI_AS” in the equal to operation. (Microsoft SQL Server, Error: 468)

Background Check Read the rest of this entry »

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)
`