YukonXML.com Home

  Search

Resources
Community
Around the Web
Things to do
About YukonXML.com
Partners



 
 Home    Daily Dose of Yukon - SQL Server 2005 Tips

Daily Dose of Yukon - SQL Server 2005 Tips

Page 1 of 11   
On this page:
NEWSEQUENTIALID()
Monday, October 17, 2005
SQL Server 2005 introduces a new T-SQL function called NEWSEQUENTIALID() that is similar to NEWID() function to generate GUIDs, except NEWSEQUENTIALID() function generates the GUID values sequentially.

Try the following in Management Studio:
USE [tempdb];
GO
CREATE TABLE dbo.tblTest 
   (c1 uniqueidentifier NOT NULL DEFAULT NEWSEQUENTIALID(),
    c2 uniqueidentifier NOT NULL DEFAULT NEWID());
GO
DECLARE @Counter INT
SET @Counter = 100
WHILE @Counter > 0
BEGIN
   INSERT INTO dbo.tblTest DEFAULT VALUES;
   SET @Counter = @Counter - 1
END
GO
SELECT * FROM dbo.tblTest;
GO
DROP TABLE dbo.tblTest;
GO
You will notice that the c1 column has sequential GUID values whereas the c2 column has random GUID values.

NEWSEQUENTIALID() Benefits:
  • You can use NEWSEQUENTIALID() to generate GUIDs to reduce page contention at the leaf level of indexes. Since the values are generated sequentially (instead of random values), NEWSEQUENTIALID() makes the column more suitable for indexing. Sequential values lead to less page splits, thus less fragmentation and clustered index performance should improve as they'll be inserted ascending and in sort order.
  • When used with a ROWGUIDCOL column in Merge Replication, NEWSEQUENTIALID() can provide increased performance when making and tracking changes.

NEWSEQUENTIALID() Limitations:
  • NEWSEQUENTIALID() can only be used with DEFAULT constraints on table columns of type uniqueidentifier. It cannot be referenced in queries.
  • It is possible to guess the value of the next generated GUID, and therefore access data associated with that GUID. If privacy is a concern, do not use this function.

SQL Server Surface Area Configuration Tool
Thursday, October 13, 2005
Microsoft SQL Server 2005 includes a tool called SQL Server Surface Area Configuration that you can use to protect your SQL Server 2005 environment by reducing the attackable area of a system. This tool provides graphical and command prompt interface to turn on or off the Database Engine settings, Analysis Services settings, Reporting Services settings, SSIS settings, Notification Services settings, SQL Server Agent settings, SQL Server Browser service settings, and Full-Text Search service settings. This tool can be launched from Start | Programs | Microsoft SQL Server 2005 | Configuration Tools program group or by running %ProgramFiles%\Microsoft SQL Server\90\Shared\SqlSAC.exe from the command line. The command prompt interface allows exporting and importing settings.

SQL Server 2005 Services
Monday, September 26, 2005
Depending on the Microsoft SQL Server components that you choose to install, SQL Server 2005 Setup installs the following ten services:
  • SQL Server Database Services (sqlservr.exe):

    Default instance: MSSQLSERVER

    Named instance: MSSQL$InstanceName

    SQL Server Database Engine.
  • SQL Server Agent (SQLAGENT90.EXE):

    Default instance: SQLServerAgent

    Named instance: SQLAgent$InstanceName

    Executes jobs, monitors SQL Server, fires alerts, and allows automation of some administrative tasks.
  • Analysis Services (msmdsrv.exe):

    Default instance: MSSQLServerOLAPService

    Named instance: MSOLAP$InstanceName

    The service that provides online analytical processing (OLAP) and data mining functionality for business intelligence applications.
  • Reporting Services (ReportingServicesService.exe):

    Default instance: ReportServer

    Named instance: ReportServer$InstanceName

    Manages, executes, renders, schedules, and delivers reports.
  • Notification Services (NSService.exe):

    Notification Services is a platform for developing and deploying applications that generate and send notifications. SQL Server Setup can install but will not configure Notification Services.
  • Integration Services (MsDtsSrvr.exe):

    Default or named instance: MSDTSServer

    Provides management support for Integration Services package storage and execution.
  • Full-Text Search (msftesql.exe):

    Default instance: MSFTESQL

    Named instance: MSFTESQL$instanceName

    Quickly creates full-text indexes on content and properties of structured and semi-structured data to allow fast linguistic searches on this data.
  • SQL Server Browser (sqlbrowser.exe): Default or named instance: SQLBrowser

    The name resolution service that provides SQL Server connection information for client computers. This service is shared across multiple SQL Server and SSIS instances.
  • SQL Server Active Directory Helper (sqladhlp90.exe):

    Default or named instance: MSSQLServerADHelper

    Publishes and manages SQL Server services in Windows active directory.
  • SQL Writer (SQLWriter.exe):

    Allows backup and restore applications to operate in the Volume Shadow copy Service (VSS) framework. There is a single instance of the SQL Writer service for all SQL instances on the server.
Following services are "instance-aware" services. This means each service is associated with a specific SQL Server instance, and has its own registry hive. You can install multiple copies of instance-aware services by running SQL Server Setup for installation of each component or service.
  • SQL Server
  • SQL Server Agent
  • Analysis Server
  • Report Server
  • Full-Text Search
Following services are "instance-unaware" services. This means these services are shared among all installed SQL Server instances; they are not associated with a specific instance, are installed only once, and cannot be installed side-by-side.
  • Notification Services
  • Integration Services
  • SQL Server Browser
  • SQL Server Active Directory Helper
  • SQL Writer

SQL Server 2000 Database Diagrams in SSMS
Monday, September 19, 2005
SQL Server 2005 database diagrams and SQL Server 2000 database diagrams are created and rendered differently. Because of these differences, SQL Server Management Studio cannot work with SQL Server 2000 diagrams. To manage SQL Server 2000 database diagrams, you must use SQL Server 2000 Enterprise Manager.

When a database containing diagrams is upgraded to SQL Server 2005, the diagrams will be upgraded the first time that the diagrams folder is opened.

You must be a member of the db_owner database role to upgrade database diagrams.

Logical and Physica CPUs
Friday, September 16, 2005
The sys.dm_os_sys_info dynamic management view (DMV) can be used to find out the number of physical and logical processors on the server:
SELECT cpu_count AS [Logical CPUs], 
       hyperthread_ratio/cpu_count AS [Physical CPUs]
FROM sys.dm_os_sys_info;

Renaming "sa" account
Sunday, September 11, 2005
The ALTER LOGIN statement can be used to rename an account in SQL Server 2005. Following T-SQL statements, rename "sa" account to "super-user":

ALTER LOGIN [sa] DISABLE;
GO

ALTER LOGIN [sa] WITH NAME = [super-user];
GO

SQL Server Management Studio Command Prompt Parameters
Thursday, August 04, 2005
SQL Server Management Studio (SQLWB.exe) accepts command prompt parameters that you can pass to connect to the specified SQL Server instance, select a particular database, use trusted or SQL authentication, specify one or more script files to open, project or solution to open, and so on. For instance, You can create or update the Management Studio shortcut, pass these parameters to launch the Management Studio connected to the server and database you want. The following sample command prompt statement launches Management Studio while connecting to a SQL Server 2005 instance called JUNECTP using trusted connection, selecting AdventureWork database, opening c:\1.sql script file and without showing the splash screen.

sqlwb c:\1.sql -S DDGXP\JUNECTP -d AdventureWorks -E -nosplash


Run sqlwb /? for more details.

Query Notifications
Monday, January 24, 2005
SQL Server 2005 and ADO.NET 2.0 introduces a new feature known as Query Notifications, which can be very handy while implementing client-tier or middle-tier caching. It is based on the notion of "Don't call us - we'll call you". In other words, your code can subscribe to results of a SQL query. If there is any change in the results, your code will be called, and you can probably refresh your result cache. Query Notification is based on Service Broker architecture leveraging all the Service Broker features such as asynchronous delivery, low overhead, highly scalable, and transaction-aware notifications. This also means that to use Query Notifications, Service Broker must be enabled for that database. The sys.dm_qn_subscriptions dynamic management view can be used to view all active query notification subscriptions. In ADO.NET 2.0, the Query Notifications functionality is provided via the SqlDependency class. See following articles and SQL Server 2005 Books Online for complete details on Query Notifications:

Limiting Result Sets Using TABLESAMPLE
Tuesday, January 04, 2005
SQL Server 2000 provides TOP keyword that can be used to limit the number of rows returned in the result set. You can specify a number indicating top n or n% rows that should be returned. SQL Server 2005 extends this keyword and now allows specifying an expression (such as a variable name) instead of only an integer number to specify the number of rows returned by the operator. TOP can also now be specified in INSERT, UPDATE, and DELETE statements.

SQL Server 2005 introduces support for TABLESAMPLE clause that like TOP allows limiting the number of rows in the result set, but unlike TOP keyword, TABLESAMPLE returns a random set of rows from throughout the set of rows processed by the query. Like TOP keyword, you can specify exact number of rows or a percentage number. Unlike TOP, TABLESAMPLE cannot be used with a view.

This sampling technique can be used to get better performance for queries on large database where absolutely exact results are NOT desired. For example, let's say you want to find approximate estimate for average employee salary, you can use TABLESAMPLE to do aggregation on sample of data rather than entire large dataset.

SQL:2003 proposal includes two sample methods: BERNOULLI and SYSTEM. SQL Server 2005 only supports SYSTEM sampling method.

SELECT AVG(SickLeaveHours) FROM HumanResources.Employee
TABLESAMPLE SYSTEM (20 PERCENT)
REPEATABLE(3);
GO

See SQL Server 2005 Books Online for more details on TABLESAMPLE clause. On a related topic, See this article on DB2 on how sampling can improve the response time.

Commenting and Uncommenting Script Blocks in SQL Server 2000 and SQL Server 2005
Monday, January 03, 2005
With SQL Server 2000, in Query Analyzer, you can select a script block and press Ctrl+Shift+C to comment it and Ctrl+Shift+R to uncomment the selected script block.

Similarly, with SQL Server 2005, in Management Studio Query Editor, you can select a script block and press Ctrl+K followed by Ctrl+C to comment the selected script block and to uncomment press Ctrl+K followed by Ctrl+U.

Page:  1  2  3  4  5  6  7  8  9  10  11     NextGo to next page (page number 2)


Microsoft® SQL Server™ 2005 "Yukon" specific information on this site is based on beta 2 of Microsoft® SQL Server™ 2005 "Yukon" and all that information on this site is subject to change at any time without prior notice.
© 2005 YukonXML.com. All rights reserved.
Home  |  Contact Us  |  Terms Of Use  |  Privacy Statement  |  RSS