Login or Sign Up to become a member!

EXPERTS, INFORMATION, IDEAS & KNOWLEDGE

Social bookmarker Add this

Your profile

Search

November 2008
Mon Tue Wed Thu Fri Sat Sun
 << <   > >>
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30

XML Feeds

Tags: sql server 2008

The Data Management Journal

Cumulative update package 2 for SQL Server 2008 is available

by SQLDenis


Permalink 19 Nov 2008 11:12 , Categories: Data Modelling & Design Tags: hotfix, sql server 2008

Cumulative update package 2 for SQL Server 2008 is available. Here is what is fixed in this cumulative update

SQL Hotfix bug numberKB article numberDescription
50003172959783FIX: A deadlock occurs when you implement DDL statements against the partitions that are defined in a partitioned table in SQL Server 2008
50003229945127FIX: You may still experience the performance issue that is described in KB article 940945 after you install Cumulative Update 3 for SQL Server 2005 Service Pack 2
50003353957812cannot merge a publication that has spatial types that include large values with a SQL Server CE subscriber
50003372956216FIX: The Transact-SQL debugger automatically saves changes to a script file when you run the script in debugging mode in SQL Server 2008 Management Studio
50003413959889FIX: When you try to install a failover instance, the unsupported X86 option is available for you to select on the options landing page in SQL Server 2008
50003417959767FIX: Memory consumption by MEMORYCLERK_SOSNODE and USERSTORE_SCHEMAMANAGER may cause a performance slowdown of a SQL Server 2008 database
50003451959768FIX: Writeback to a measure group is not reflected in a linked measure group
50003457957815FIX: A SQL Server 2008 query returns incorrect results when you create a spatial index in a table that contains a composite primary key
50003504959769FIX: A DMX prediction query returns incorrect results when you query a logistic regression model in SQL Server 2008 Analysis Services
50003529959770FIX: Column data is incorrect when a lot of data is processed by the SSIS Fuzzy Grouping transformation
50003541959771FIX: Excel 2007 cannot connect to an OLAP cube on a server that is running SQL Server 2005
50003542959773FIX: When you use Excel 2007 Service Pack 2 to make a subselect query with calculated members, the query returns unexpected error
50003543959774FIX: The Excel 2007 Filter function does not evaluate calculated members so that Excel PivotTable advanced filters return unexpected results
50003562959776FIX: Visual Studio 2008 stops responding when you leave a SQL Server 2008 Analysis Services-based database project idle for some time
50003580958479FIX: Error message when you try to export a SQL Server 2008 Reporting Services report by using Report Manager: “Internet Explorer cannot download <ReportName>.xls from <URL>”
50003600959788FIX: In SQL Server 2008, Dr. Watson error information is not posted in the Problem Reports and Solutions window if setup fails
50003601959792FIX: Some screens in the Cumulative Update 1 for Microsoft SQL Server 2008 setup contain incorrect information
50003608959794FIX: Error message when you use a SQL Server 2008 SSIS package to query a table in an Oracle database: “SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR”
50003611958611FIX: You may receive incorrect results when you run a query that references three or more tables in the FROM clause in SQL Server 2008
50003617958599FIX: The output from the DBCC MEMORYSTATUS command indicates that the Schema Manager cache uses more buffer space than expected in SQL Server 2008
50003623958496FIX: You receive error code 18834 from Replication Log Reader agent when transactional replication starts in SQL Server 2008
50003626956031FIX: Error message when you estimate the compression on a table in SQL Server 2008: “Subquery returned more than 1 value”
50003627959796FIX: An ODBC function sequence error occurs when you try to send a table-valued parameter by using the data-at-execution mechanism in SQL Server 2008
50003644959780FIX: When an AMO object is used in the SQL Server 2008 CLR stored procedure to create or update Analysis Services objects, the stored procedure may fail
50003660958757FIX: You cannot use the SQL Server 2008 SMO to manage certificates in Microsoft SQL Server 2005 and 2000
50003661958758FIX: Full-text search functionality does not work in SQL Server 2008 Express Edition
50003662958759FIX: The recovery model is different when you create a new database by using SSMS
50003665958762FIX: When you delete a maintenance plan in a restored SQL Server 2008 database, the maintenance plan is also deleted on the server from which the database was originally backed up
50003668958790FIX: Management Studio: When you try to generate a “Drop Table” script SQL Server Management Studio generates a “Create Table” script instead
50003669958792FIX: You cannot rebuild an index by using the REBUILD argument together with the ALTER TABLE statement or the ALTER INDEX statement if the table uses Sparse Columns as defined in SQL Server Management Studio
50003670958793FIX: Generate script wizard is missing tables when the source database is case-insensitive
50003675958214FIX: Query could return incorrect results if a passthrough predicate is used with a filter in its query plan
50003676958208FIX: When you call the SQLExecute function to run a query after you set the SQL_ATTR_ROW_ARRAY_SIZE attribute, you may obtain incorrect results in SQL Server 2008
50003684959798FIX: A query that uses a DMV to query the sys.dm_os_performance_counters seems to stop responding in SQL Server 2008
50003690958918FIX: The setup of SQL Server 2008 may not be successful
50003693958941FIX: The “Most Expensive Queries” chart in the Activity Monitor does not show database name or database ID number on a server that is running SQL Server 2008
50003695958942FIX: Activity Monitor shows high wait times when the FSAgent wait type is enabled on a server that is running SQL Server 2008
50003696958943FIX: The Database or Task State columns may be blank for some processes in Process chart of Activity Monitory on a server that is running SQL Server 2008
50003697959782FIX: You cannot access Books Online help from the Activity Monitor feature in SQL Server 2008 when you press F1
50003699959801FIX: When you try to patch SQL Server 2008, the patch for SQL Support is not successful
50003700959800FIX: When you try to install Business Intelligence Development Studio in SQL Server 2008, the installation may not be successful
50003701954950FIX: Error message when you run a distributed query in SQL Server 2005 or SQL Server 2008: “OLE DB provider ‘SQLNCLI’ for linked server ‘<Linked Server>’ returned message ‘No transaction is active’”
50003706959795FIX: The License Terms screen of the Setup program for Cumulative Update 1 for SQL Server 2008 incorrectly states “To install Service Pack”
50003715959376FIX: Error message when you run the DBCC SHRINKFILE command or the DBCC SHRINKDATABASE command on a server that contains a SQL Server 2008 database: “5205 : DBCC SHRINKFILE: Moving Page <FileId>:<PageId> failed”
50003717959790FIX: Database Engine Tuning Advisor in SQL Server 2008 does not recommend any index to analyze a query
50003724956298FIX: When you download the Report Builder ClickOnce application of SQL Server 2005 Reporting Services or SQL Server 2008 Reporting Services, the Reportbuilder.chm.deploy file is downloaded as the text/html content type instead of the application/octet-str
50003728956254FIX: You may obtain an incorrect result when you use a cursor to perform DML operations on a table that does not have a clustered index in SQL Server 2008 or in SQL Server 2005
50003732959789FIX: Error message when you run the snapshot agent on a replication of a stored procedure in SQL Server 2005: “The Name property cannot have a value of @param_name for this version of SQL Server”
50003735956889FIX: Error message when you run the snapshot agent on a replication of a stored procedure in SQL Server 2005 or in SQL Server 2008: “The Name property cannot have a value of @param_name for this version of SQL Server”
50003736959032FIX: A peer-to-peer transactional replication does not replicate rows if you rebuild the index for a published table at the same time as you insert data in the published table in SQL Server 2005
50003741958555FIX: A SQL Server Agent job that creates a ServerXMLHTTP object by using an ActiveX script remains in the Executing status and is never completed in SQL Server 2005
50003750958006FIX: The size of the SQL Server 2005 error log file grows very quickly when query notifications are created and destroyed in a high ratio
50003792959785FIX: Error message when you try to add articles to a publication that uses an Oracle Database 11g database as the publisher in SQL Server 2008: “Constraint column ‘<ColumnName>’ not found in table ‘<TableName>’”
50003796959784FIX: Error message when you synchronize data for a transactional publication in SQL Server 2008: “Procedure or function ’sp_MSins_dbo<TableName>_msrepl_ccs’ expects parameter ‘@c7′, which was not supplied”

You can get information on how to obtain this cumulative update here: http://support.microsoft.com/default.aspx/kb/958186/en-us

Leave a comment »Send a trackback » 305 views

Cumulative Update 1 to the RML Utilities for Microsoft SQL Server Released

by SQLDenis


Permalink 12 Nov 2008 13:44 , Categories: Data Modelling & Design Tags: sql server 2008

What Are the RML Utilities?

The Microsoft SQL Server support team uses several internally written utilities to ease the work that is related to a typical customer support case.  One such utility suite is the Replay Markup Language (RML) Utilities for SQL Server.  Database developers and system administrators can use the RML Utilities to work with Microsoft SQL Server 2000, Microsoft SQL Server 2005 and Microsoft SQL Server 2008.

You can use the RML Utilities for SQL Server to perform the following tasks:

  • You can determine the application, the database, the SQL Server login, or the query that is using the most resources.
  • You can determine whether the execution plan for a batch is changed when you capture the trace for the batch.  Additionally, you can use the RML Utilities for SQL Server to determine how SQL Server performs each of these execution plans.
  • You can determine the queries that are running slower than before.

After you capture a trace for an instance of SQL Server, you can use the RML Utilities for SQL Server to replay the trace file against another instance of SQL Server. If you also capture the trace during the replay, you can use the RML Utilities for SQL Server to compare the new trace file to the original trace file. You can use this technique to test how SQL Server behaves after you apply changes. For example, you can use this technique to test how SQL Server behaves after you do the following:

  • You install a SQL Server service pack.
  • You install a SQL Server hotifx.
  • You update a stored procedure or a function.
  • You update an index or create an index.

The RML Utilities are very useful if you want to simulate application testing when it is impractical or impossible to test by using the real application.  For example, in a test environment, it may be difficult to generate the same user load that exists in the production environment.  You can use the RML Utilities to replay a production workload in a test environment and assess the performance impact of changes such as an upgrade to SQL Server 2008 or application of a SQL Server service pack.  Additionally you can use the RML Utilities to analyze and compare various replay workloads.  This kind of regression analysis would otherwise be a difficult process that you would have to perform manually.

Version 9.01 of the RML Utilities for Microsoft SQL Server has been released. This release of the RML Utilities provides support for SQL Server 2000, SQL Server 2005 and SQL Server 2008. Additionally this release of the RML Utilities for SQL Server contains important software updates, enhanced features and reports, and performance and scalability improvements.

To download the current web release of the RML Utilities for SQL Server visit the following Microsoft Web site:

RML Utilities for SQL Server (x86) - http://www.microsoft.com/downloads/details.aspx?FamilyID=7edfa95a-a32f-440f-a3a8-5160c8dbe926

RML Utilities for SQL Server (x64) - http://www.microsoft.com/downloads/details.aspx?FamilyID=b60cdfa3-732e-4347-9c06-2d1f1f84c342

Leave a comment »Send a trackback » 295 views

What is wrong with this code?

by SQLDenis


Permalink 12 Nov 2008 08:51 , Categories: Data Modelling & Design, Database Programming, Microsoft SQL Server Tags: coding, sql server 2005, sql server 2008

Take a look at this code which I found a while back in a stored proc

  1. DECLARE @id INT,@xtype CHAR(1),@uid INT,@info INT,@status INT
  2.  
  3. SET  @id =(SELECT id FROM sysobjects WHERE name = ’sysobjects’)
  4. SET @xtype  =(SELECT xtype FROM sysobjects WHERE name = ’sysobjects’)
  5. SET @uid   =(SELECT uid FROM sysobjects WHERE name = ’sysobjects’)
  6. SET @info  =(SELECT info FROM sysobjects WHERE name = ’sysobjects’)
  7. SET @status =(SELECT status FROM sysobjects WHERE name = ’sysobjects’)
  8.  
  9. SELECT @id ,@xtype ,@uid ,@info ,@status
  10. go

Do you see what is wrong? It uses five select statements to accomplish something which can be done in one. I would do something like this instead.

  1. DECLARE @id INT,@xtype CHAR(1),@uid INT,@info INT,@status INT
  2.  
  3. SELECT @id =id
  4. ,@xtype =xtype
  5. ,@uid =uid
  6. ,@info =info
  7. ,@status =status
  8. FROM sysobjects WHERE name = ’sysobjects’
  9.  
  10. SELECT @id ,@xtype ,@uid ,@info ,@status

Let’s take a look at another example.

What we want to do is display a row of counts for 4 xtypes from the sysobjects table, here is an example

s	u	p	c
19	143	74	6

Have you ever seen code like this that does that? I have!

  1. SELECT COUNT(*) AS [s],
  2. (SELECT COUNT(*) FROM  sysobjects WHERE xtype = ‘u’) AS [u],
  3. (SELECT COUNT(*) FROM  sysobjects WHERE xtype = ‘p’) AS [p],
  4. (SELECT COUNT(*) FROM  sysobjects WHERE xtype = ‘c’) AS [c]
  5. FROM  sysobjects
  6. WHERE xtype = ’s’

That code will do a select 4 times against the table
A better way would be to do this

  1. SELECT  SUM(CASE xtype WHEN ’s’ THEN 1 ELSE 0 END) AS [s],
  2. SUM(CASE xtype WHEN ‘u’ THEN 1 ELSE 0 END) AS [u],
  3. SUM(CASE xtype WHEN ‘p’ THEN 1 ELSE 0 END) AS [p],
  4. SUM(CASE xtype WHEN ‘c’ THEN 1 ELSE 0 END) AS [c]
  5. FROM sysobjects
  6. WHERE xtype in(’s’,‘u’,‘p’,‘c’)

In SQL server 2005/2008 you can use the PIVOT operator, here is what the query would look like

  1. SELECT s, u, p, c
  2. FROM
  3. (SELECT xtype
  4. FROM sysobjects
  5. WHERE xtype IN(’s’,‘u’,‘p’,‘c’)) AS pivTemp
  6. PIVOT
  7. (   COUNT(xtype)
  8.     FOR xtype IN(s, u, p, c)
  9. ) AS pivTable

If you can think of any other examples feel free to leave a comment

Leave a comment »Send a trackback » 329 views

Finding Fragmentation Of An Index And Fixing It

by SQLDenis


Permalink 07 Nov 2008 09:45 , Categories: Data Modelling & Design Tags: fragmentation, indexing, maintenance, sql server 2005, sql server 2008

A lof of time your index will get framented over time if you do a lot of updates or insert and deletes.
We will look at an example by creating a table, fragmenting the heck out of it and then doing a reorganize and rebuild on the index

First create this table

  1. CREATE TABLE TestIndex (name1 VARCHAR(500)
  2. not null,id INT
  3. not null,userstat  INT not null,
  4. name2 VARCHAR(500) not null,
  5. SomeVal UNIQUEIDENTIFIER not null)

Now insert 50000 rows

  1. INSERT TestIndex
  2. SELECT TOP 50000 s.name,s.id,s.userstat,s2.name,newid()
  3. FROM master..sysobjects s
  4. CROSS JOIN master..sysobjects s2

Now create this index

  1. CREATE CLUSTERED INDEX IX_TestIndex_Index ON TestIndex(SomeVal)

Now let us look at some data by using the sys.dm_db_index_physical_stats DMV. Keep this query handy, we will run it many times

  1. SELECT OBJECT_NAME(OBJECT_ID) AS Tablename,s.name AS Indexname
  2. ,index_type_desc
  3. ,avg_fragmentation_in_percent
  4. ,page_count
  5. FROM sys.dm_db_index_physical_stats (DB_ID(), NULL, NULL , NULL, N‘LIMITED’) d
  6. join sysindexes s ON d.OBJECT_ID = s.id
  7. and d.index_id = s.indid
  8. and s.name =‘IX_TestIndex_Index’


(Result Set)

Tablename Indexname index_type_desc avg_fragmentation_in_percent page_count
TestIndex IX_TestIndex_Index CLUSTERED INDEX 0.22172949002217296 451

That is good, almost no fragmentation. Let’s change that shall we?

  1. UPDATE TestIndex
  2. SET SomeVal = NEWID()

Okay, now you can see that the index is completely fragmented, we are also using 955 pages to store the data instead of 451
(Result Set)

Tablename Indexname index_type_desc avg_fragmentation_in_percent page_count
TestIndex IX_TestIndex_Index CLUSTERED INDEX 99.3717277486911 955

There are two ways to fix fragmentation, one is to reorganize the index and the other is to rebuild the index. Reorganize is an online operation while rebuild is not unless you specify ONLINE = ON, ONLINE = ON will only work on Enterprise editions of SQL Server.
Here is how to do a reorganize

  1. ALTER INDEX IX_TestIndex_Index ON TestIndex
  2. REORGANIZE;

(Result Set)

Tablename Indexname index_type_desc avg_fragmentation_in_percent page_count
TestIndex IX_TestIndex_Index CLUSTERED INDEX 2.8824833702882482 451


As you can see after the reorganize(DBCC INDEXDEFRAG for you SQL Server 2000 folks) fragmentation levels dropped to less than 3 percent.

Just for fun let’s also rebuild(Drop and recreate the index for you SQL Server 2000 folks) the index

  1. ALTER INDEX IX_TestIndex_Index ON TestIndex
  2. REBUILD;

(Result Set)

Tablename Indexname index_type_desc avg_fragmentation_in_percent page_count
TestIndex IX_TestIndex_Index CLUSTERED INDEX 0.22222222222222221 450

As you can see the rebuild made fragmentation almost 0

Here are two differences between REBUILD ONLINE = ON and REBUILD ONLINE = OFF
ON
Long-term table locks are not held for the duration of the index operation. During the main phase of the index operation, only an Intent Share (IS) lock is held on the source table. This allows queries or updates to the underlying table and indexes to continue. At the start of the operation, a Shared (S) lock is very briefly held on the source object. At the end of the operation, an S lock is very briefly held on the source if a nonclustered index is being created, or an SCH-M (Schema Modification) lock is acquired when a clustered index is created or dropped online, or when a clustered or nonclustered index is being rebuilt. ONLINE cannot be set to ON when an index is being created on a local temporary table.

OFF
Table locks are applied for the duration of the index operation. An offline index operation that creates, rebuilds, or drops a clustered, spatial, or XML index, or rebuilds or drops a nonclustered index, acquires a Schema modification (Sch-M) lock on the table. This prevents all user access to the underlying table for the duration of the operation. An offline index operation that creates a nonclustered index acquires a Shared (S) lock on the table. This prevents updates to the underlying table but allows read operations, such as SELECT statements.

Of course you will not run rebuild/reorganize manually for every index in your database, Michelle Ufford from the SQL Fool blog has a nice post with just a script which can do this automatically, you can find that here: Index Defrag Script

This post is also on our SQL Server Admin Hacks

1 comment »Send a trackback » 1811 views

Create a sorted view in SQL Server 2005 and SQL Server 2008

by SQLDenis


Permalink 05 Nov 2008 12:20 , Categories: Data Modelling & Design Tags: pitfalls, sql server 2005, sql server 2008, views

I saw that some people are hitting our site with a search for how to create a sorted view in SQL Server 2008.

You all know that in SQL Server 2000 you can create a view and use TOP 100 PERCENT with ORDER By and it will be sorted. Since SQL server 2005 that doesn’t work anymore. I actually never understood the need for sorted views to begin with, how hard is it to do something like this

  1. SELECT *
  2. FROM VIEW
  3. ORDER BY COLUMN

Not hard, I guess pople want the convenience of opening the view in SSMS and it is sorted ‘correctly’
There is a way to get this to work in SQL server 2005, there is a hotfix that will ‘fix’ this but you have to run in 2000 compatability mode.
The link to the fix is here: FIX: When you query through a view that uses the ORDER BY clause in SQL Server 2008, the result is still returned in random order

Now let’s get started with the code
Create this table

  1. CREATE TABLE TestSort (id INT not null)
  2. INSERT TestSort VALUES(1)
  3. INSERT TestSort VALUES(3)
  4. INSERT TestSort VALUES(4)
  5. INSERT TestSort VALUES(5)
  6. INSERT TestSort VALUES(2)
  7. INSERT TestSort VALUES(7)
  8. INSERT TestSort VALUES(9)
  9. INSERT TestSort VALUES(6)

And create the view

  1. CREATE VIEW vTestSort
  2. AS
  3. SELECT TOP 100 PERCENT id FROM TestSort
  4. ORDER BY id

Now do a select from the view

  1. SELECT * FROM vTestSort

(result set)
1
3
4
5
2
7
9
6

Oops it is not sorted
Let’s try something else, we will use 99.99 percent

  1. CREATE VIEW vTestSort2
  2. AS
  3. SELECT TOP 99.99 PERCENT  id FROM TestSort
  4. ORDER BY id

Run the select against the view

  1. SELECT * FROM vTestSort2

(result set)
1
2
3
4
5
6
7
9

look at that, magic! It works

Let’s try another way by using the max value of an integer

  1. CREATE VIEW vTestSort3
  2. AS
  3. SELECT TOP 2147483648 id FROM TestSort
  4. ORDER BY id

Run the select against the view

  1. SELECT * FROM vTestSort3

(result set)
1
2
3
4
5
6
7
9

And bingo, it also works.

Now, just because this works right now it doesn’t mean that it will work after you apply the next hotfix or service pack. Why not doing this instead

  1. SELECT * FROM vTestSort3
  2. ORDER BY id

That will always work and you don’t have to deal with unexpected results down the road

Leave a comment »Send a trackback » 675 views

:: Next >>