Monthly Archives: April 2011

SQLXML: Fun with SQLXML XQuery – Miscellaneous Functions – Part 1

Just going through some old notes; here are some samples I compiled before that might still be of interest to those of you who are venturing into SQLXML.

The samples below are using miscellaneous numeric and string functions.

Have fun!

Sample XML

[sql]
DECLARE @xml XML
SELECT @xml = ‘
<Employees Dept=”IT”>
<Employee Number=”1001″ Hourly=”11.35″ FullName=”Suzy Jacobs”>
<FName>Suzy</FName>
<LName>Jacobs</LName>
<Phone>111-111-1111</Phone>
<Phone>222-222-2222</Phone>
<Phone>111-222-1111</Phone>
</Employee>
<Employee Number=”10″ FullName=”Bob Willow” ReportsTo=”Steve Wong”/>
<Employee Number=”1003″ FullName=”Tony Carpenter” FName=”Tony” LName=”Carpenter”/>
<Employee Number=”1004″ FullName=”Suzy Jacobs” FName=”Suzy” LName=”Jacobs”/>
<Staff Number=”1003″ FName=”John” FullName=”John Smith” LName=”Smith” Department=”ABC” />
<MoreStaff Number=”1020″ FullName=”Ronnie Bates” FName=”Ronnie” LName=”Bates” Address=”XYZ” Department=”ABC” />
</Employees>’
[/sql]

Read more

Advertisements

Understanding SQL Server Statistics

Originally posted on Idera – http://sqlserverperformance.idera.com/tsql-optimization/understanding-sql-server-statistics/

“Statistics provides tools that you need in order to react intelligently to information you hear or read” – David Lane, 2003

If there’s an upcoming election and you are running for office and getting ready to go from town to town city to city with your flyers, you will want to know approximately how many flyers you’re going to bring.

If you’re the coach of a sports team, you will want to know your players’ stats before you decide who to play when, and against who. You will often play a matchup game, even if you have 20 players, you might be allowed to play just 5 at a time, and you will want to know which of your players will best match up to the other team’s roster. And you don’t want to interview them one by one at game time (table scan), you want to know, based on their statistics, who your best bets are.

Just like the election candidate or the sports coach, SQL Server tries to use statistics to “react intelligently” in its query optimization. Knowing number of records, density of pages, histogram, or available indexes help the SQL Server optimizer “guess” more accurately how it can best retrieve data. A common misnomer is that if you have indexes, SQL Server will use those indexes to retrieve records in your query. Not necessarily. If you create, let’s say, an index to a column City and <90% of the values are ‘Vancouver’, SQL Server will most likely opt for a table scan instead of using the index if it knows these stats.

Read more

Troubleshooting Replication Error: A required privilege is not held by the client

Troubleshooting Replication Error: A required privilege is not held by the client

If you ever you encounter this replication issue, the resolution might be fairly simple, however it will require that you toggle your SQL Service accounts.

Have a look at this KB:
http://support.microsoft.com/kb/911305/en-us

The KB suggests the service account might have changed using a tool other than the Configuration Manager (technically a no-no because the SSCM, in addition to changing the service accounts, also performs updates to associated settings like windows registry entries). Try toggling the service accounts in Configuration Manager (for ex, from Administrator, to something Local, to administrator again) and that should flush the old credentials.

Read more

@msshushu’s and @sqlbelle’s take on “Why BCIT”?

Shereen (blog | @msshushu) and I are going to participate tonight at BCIT’s Info Session for the School of Computing.

Shereen and I are both true blue BCIT alumni. We both have our CST Diplomas from BCIT, and both pursued our degrees at BCIT.

There are a lot of reasons why we went to BCIT, and why going to BCIT worked for us.
Here’s our take on “Why BCIT?”

BCIT-Info-Session-Presentation-Shereen-and-Donabel-v1.11

Invalid Credentials Error During SQL Server 2008/R2 Install

In case you get the following errors:

The credentials you provided for the SQL Server Agent service are invalid. To continue, provide a valid account and password for the SQL Server Agent service.

The specified credentials for the SQL Server service are not valid. To continue, provide a valid account and password for the SQL Server service.

Here’s the simple solution:
http://www.jadota.com/2009/01/the-credentials-you-provided-during-sql-server-2008-install-are-invalid/

Meme Monday – SQL Server Story in 11 Words or Less

I’ve been tagged by the awesome tweep/blogger, Janice C Lee (blog | twitter) for Tom LaRock’s (blog | twitter) Meme Monday (Write a SQL blog post that tells a story in 11 words or less).

Here’s my 11-words-or-less-sql-story:

It’s fun working with SQL Server. Sometimes stressful, but always fun.

Now I want to tag another 3 awesome tweeps/bloggers:

Wendy Pastrick (blog | twitter)
Michelle Ufford (blog | twitter)
Kendra Litte (blog | twitter)

Happy Monday everyone!