Saturday, April 11, 2009

Rebuild System Databases in SQL Server 2008

The syntax for using setup.exe to rebuild the system databases is as follows:

setup.exe
/QUIET
/ACTION=REBUILDDATABASE
/INSTANCENAME=instance_name
/SQLSYSADMINACCOUNTS= accounts
[/SAPWD=password]
[/SQLCOLLATION=collation_name]


Here are the details about how to use this syntax and how it works:

1. Find setup.exe either from your original media or the "local" setup.exe as found in the directory where you have installed SQL Server in the 100\Setup BootStrap\Release directory. So on my machine, I changed directory to C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\Release.
2. Run setup.exe with the following syntax from a Windows command prompt:
If you have SQL configured for Windows Authentication Mode use this syntax:
setup /ACTION=REBUILDDATABASE /QUIET /INSTANCENAME= /SQLSYSADMINACCOUNTS=
where is either the name of your named instance or MSSQLSERVER for the default instance
are Windows groups or individual accounts to provision as sysadmin If you have SQL configured for Mixed Authentication Mode use the same syntax except you must also provide the /SAPWD parameter to specify the SA password. If you don't, you will get an error.
If you want to rebuild the system databases with a different collation than what you used to install SQL Server, you would need to supply the /SQLCOLLATION parameter. If you don't supply this parameter, then SQL Server will rebuild the system databases with the collation you selected when you installed SQL Server.
3. When setup has completed rebuilding the system databases, it will return to the command prompt with no messages (It always first prints out the version). If you have any syntax problems or issues with parameters you will see these errors in the command window. If you don't see any errors, then you will need to examine the "Summary" log file to verify it was completely successful.
4. If you immediately go to the directory where logs are stored for setup (100\setup bootstrap\logs), you can open up a file called Summary.txt. This file represents the most recent summary of any execution of setup. If you run setup for any other reason after rebuilding the databases before you look at the summary.txt file you will have to look for a folder inside the logs directory that matches the datetime when you run setup to rebuild the system databases. This may not be something that is simple to do if you have run setup several times so a tip here is to use findstr.exe from the command prompt like the following:
findstr /s RebuildDatabase summary*.*
This search will point you to any summary files that are for rebuilding system databases because this is the string printed in the Summary setup log file when using setup for this purpose. Here is an example "top portion" of a Summary setup log file when rebuilding system databases was successful:

Overall summary:
Final result:
Passed
Exit code (Decimal): 0
Exit message: Passed
Start time: 2008-08-29 08:09:10
End time: 2008-08-29 08:10:25
Requested action: RebuildDatabase

Here are a few interesting notes to consider about how this feature works:
You don't need your DVD anymore!
A new feature different from previous versions of SQL Server is that the system databases files we use to rebuild the current system databases do not come from the original installation media. So where do they come from? The come from the installation folder on your local computer in BINN\templates. On my machine where I installed SQL Server 2008 RTM on a clean machine with the default instance, this full path was at:
C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\Binn\Templates
In this directory you will find master, model, and msdb database and log files that were copied from your installation source as part of setup.
So the logic in rebuilding the system databases is to get these files and copy them into your DATA directory to obtain your new system databases. This is a very nice enhancements for rebuilding system databases because you are not required to have your DVD or original install media.
However, If these files are missing, then setup will fail and your summary log may look something like this:
Overall summary: Final result: Failed: see details below Exit code (Decimal): -2068643839 Exit facility code: 1203 Exit error code: 1 Exit message: Failed: see details below Start time: 2008-08-29 08:30:42 End time: 2008-08-29 08:31:32 Requested action: RebuildDatabase
Later down in the summary log file you will see the details like the following example:
Detailed results: Feature: Database Engine Services Status: Failed: see logs for details MSI status: Passed Configuration status: Failed: see details below Configuration error code: 0x8C77B9A8@1306@25 Configuration error description: The file C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\Binn\Templates\master.mdf is missing. Configuration log: C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\Log\20080829_083014\Detail.txt
The details show the problem. master.mdf is missing from the templates directory. The way to resolve this is to either
1) Use the Repair feature of Setup (Available from the Maintenance option of the SQL Server Installation Center installed your machine)
2) Manually copy the necessary file(s) yourself. On your media source find the directory of your platform (x86, x64, or ia64). Then go to the following directory:
setup\sql_engine_core_inst_msi\PFiles\SqlServr\MSSQL.X\MSSQL\Binn\Template
Once you have copied the file into the templates directory, re-run setup with the syntax I've described above.
What about the Resource Database?
This feature does not attempt to restore the resource database files mssqlsystemresource.mdf or mssqlsystemresource.ldf. In fact, these files are considered part of the software so are now installed in the BINN directory. Therefore, to rebuild these database files you would need to run Repair from the Installation Center.

Tuesday, March 17, 2009

Backup Database script

Below script describe how to backup database and output file include current date


DECLARE @filename NVARCHAR ( 500 )
SET @filename = 'C:\ABC_' + CONVERT(NVARCHAR, GETDATE(),112) + '.BAK'
BACKUP DATABASE ABC TO DISK = @filename


Happy code ;)

Sunday, December 28, 2008

What's New in PerformancePoint SP2?


Planning
Support for Windows Server 2008 Hyper-V™
You can now use PerformancePoint Server 2007 SP2 with Windows Server 2008 Hyper-V.
Hyper-V creates new opportunities for server virtualization. You can use Hyper-V to make more efficient use of system hardware and host operating system resources to reduce the overhead that is associated with virtualization.
For more information, see the
PerformancePoint Server 2007 Hyper-V guide.


Monitoring

  1. You can now use SQL Server 2008 with PerformancePoint Server 2007 SP2.
    Important: To use SQL Server 2008 with PerformancePoint Server, you must install PerformancePoint Server 2007 SP2 before you install SQL Server 2008.
    You can now use the Show Details action on PerformancePoint reports that use data that is stored in SQL Server 2008 Analysis Services.
  2. Show Details enables dashboard consumers to right-click in a cell or on a chart value and see the transaction-level details for that value.
    PerformancePoint Server 2007 with SP2 now supports Windows Server 2008 Hyper-V.
    Hyper-V creates new opportunities for server virtualization. You can use Hyper-V to make more efficient use of system hardware and host operating system resources to reduce the overhead associated with virtualization.
    For more information, see the
    PerformancePoint Server 2007 Hyper-V guide (http://go.microsoft.com/?linkid=9639690).
  3. You can now use Dashboard Designer on a computer that us running .NET Framework 3.5 alongside .NET Framework 2.0.
    You must install .NET Framework 2.0 before you install .NET Framework 3.5.
    You can now use PerformancePoint Server with domains that have apostrophes in their names
    In previous versions of PerformancePoint Server, when a domain name included an apostrophe, the configuration tool failed for both Planning Server and Monitoring Server.
  4. Scorecard key performance indicator (KPI) queries are improved.
  5. Timeout errors no longer occur with scorecard key performance indicators (KPIs) that use data that is stored in SQL Server 2005 Analysis Services.
  6. Time Intelligence Post Formula filters now display the correct number of days for each month.
    In previous versions of PerformancePoint Server, the calendar control for Time Intelligence Post Formula filters sometimes displayed 31 days for each month. This is no longer the case.
  7. Time Intelligence filters now work on scorecard KPIs that use data that is stored in Analysis Services
    In previous versions of PerformancePoint Server, some Time Intelligence expressions caused filters that were linked to KPIs to fail.
    For example, when a compound expression such as (Day-7:Day-1) was used in a Time Intelligence Post Formula filter and that filter was linked to a KPI, an error message occurred. In PerformancePoint Server 2007 PS2, single and compound Time Intelligence expressions work with KPIs that use data that is stored in Analysis Services.

Sunday, November 2, 2008

Download SQL Server 2005 Service Pack 3 - CTP

The CTP version of SQL Server 2005 Service Pack 3 (SP3) is now available. You can use these packages to upgrade any of the following SQL Server 2005 editions:

  • Enterprise
  • Enterprise Evaluation
  • Developer
  • Standard
  • Workgroup

For a summary list of What’s new in SQL Server 2005 SP3 CTP, review the What’s New document.

These packages have been made available for general testing purposes only. Do not deploy the CTP software in production.

Download SQL Server 2005 Service Pack 3

Wednesday, July 30, 2008

SQL Server 2008 SSMS Enhancements - Part I

I have just installed SQL Server 2008 RC0 and had been playing a bit with the new Management Studio. I found a few interesting features. I will try to cover some of those features in this post.
The new cool splash screen SQL Server 2008 has got an all new logo and splash screen.
Activity Monitor
The next feature that attracted me is the new "Activity Monitor".
It opens a window that displays the server activities.


What I found most useful is the section that shows "Recent Expensive Queries". One of the tasks that I do quite often is the optimization of "bad" queries or even "well written" queries that does not perform well enough. This panel of the activity monitor seems to be a good tool which readily shows me the stuff that I need to work on.
Missing Index hints in Graphical Execution Plan
Another change that I noticed instantly is the addition of Missing Index Hints in the query execution plan.
You could right click on the index hint and it will show a context menu that will take you to the details of the missing index.

Thursday, July 24, 2008

Upgrade live applications to SQL Server 2005 for high availability

Most companies have the luxury of upgrading their applications in place. But for many industries such as credit card, banking, shopping and gaming companies, the prospect of downtime is unacceptable. Imagine eBay/PayPal taking the system down for even one hour for an upgrade. The costs quickly escalate into the millions in just lost immediate revenue, not to mention the customers that would be lost to competitors.
The challenge
Your boss has told you that the ordering application has to be upgraded to version 10 with less than 15 minutes downtime. The database in question is 4+ TB and takes 16 hours to upgrade without any traffic running to it.
Reality check
The best laid ideas often fail because the scope of the project is not set early on and strictly adhered to. You will probably need to focus on a few key application areas that are critical to convert live. In eBay's case, it might say that, throughout the course of the upgrade, activities such as placing auctions, bids, payments and so on have to be live, but it's acceptable if you can't provide feedback or account merges. Try to avoid converting any data live, but keep each functional unit (block of tables) intact and transfer them live.

Hypothetical process
What process you pick, is heavily dependent on your budget. In this hypothetical scenario, we'll use two clusters with two nodes each. But you could easily simulate this scenario using two SQL Server instances on the same physical (or cluster) box or virtual servers running something like VMware's ESX. Let's examine the figure below.

Using two clusters and two nodes for live application upgrade.
Stage 1
In stage 1, we have the live data flowing into the current version of the database application. We created a second conversion database on Cluster 1 that contains any tables we want to convert over to the upgraded database – while the application is live. The most important part at this point is determining how to maintain consistency in the tables. The most common method is saving off of the current date/reference number for all conversion data at the time you want to start converting. Then continually you'd use a job that fires off stored procedures to bring over dates/reference numbers greater than the initial numbers you saved off. You could use other methods, such as triggers or Service Broker, but both would involve modifications to the original database schema and increase your risk and chance of making a mistake.
Stage 2
Stage 2 is a second physical cluster (or second instance/virtual server, depending on budget). As far as the schema goes, the conversion database on Cluster 2 exactly matches the conversion database on Cluster 1.
As the application pushes live data into the Order App DB (V9), the SQL Agent job on Cluster 1 fires off stored procedures that move the data into the conversion database on Cluster 1. Once the data reaches the conversion database, you can set up a replication publication on Cluster 1 for the conversion database that has a subscription running on Cluster 2. This causes any data pushed into the conversion database to transfer almost immediately into the conversion database on Cluster 2.
As the application is live pushing data into Cluster 1's version 9 database and is replicated over to the conversion database on Cluster 2, you can run the database upgrade process on Cluster 2's Order App DB – which you already restored from production at some point. Regardless of the time the database upgrade takes to run, the live data will be flowing into the conversion database on Cluster 2. Once the database upgrade is complete, you can fire off the SQL Server Agent job on Cluster 2; this fires off stored procedures that convert the version 9 data tables in the conversion database into the upgraded version 10 database sitting on Cluster 2. At this point, you'll have a chance to do any necessary configuration/maintenance to the upgraded version 10 database.
Stage 3
Once the conversion database on Cluster 2 is close to empty and the clients are upgraded to version 10, it's time to simply turn off Cluster 1 and point all the clients to Cluster 2, which already have all the critical live data transferred. A quick method of switching clients to version 10 would be SMS or SoftGrid (application virtualization), or some other method of automatically deploying a new version of a client en masse to a large client base. This would allow you to deploy version 10 applications within 15 minutes and they'd point to the freshly upgraded version 10 database on Cluster 2.
Summary
Upgrading an application while it is live requires that a lot of custom code be written to ensure the tables are consistent between the clusters (servers or instances). Test the upgrade scenario/scripts out several times, verifying reports at all the various stages to make sure the upgrade flows like clockwork. Verifying the various conversion database processes and jobs and documenting and ensuring consistency is fairly boring work, but it will pay off in the end when the upgrade flows smoothly. It beats working out issues within the user's sight.

Tuesday, July 22, 2008

Configure IBM Cognos 8.3 with IIS 7 and Windows Vista

One of the common problems I has facing is Configure IBM Cognos 8.3 with IIS 7 and Windows Vista for that I summarize the configuration in the following steps hoping be useful

1. In IIS7 goto your device name
2. There in the center screen open ISAPI and CGI RESTRICTIONS
3. On the right screen click add
4. the path: %windir%\system32\inetsrv\cgi.dll (if you dont have this file, install it from the 'turn windows features on/off) where you can find it under the IIS component.
5. Name this thing something like 'dot cgi'
6. Allow it to execute -> done
7. Now click on the right screen 'edit feature settings' and allow cgi (I allowed both cgi and isapi )
8. Click on your device name again and in the center screen open 'Handler mappings'
9. Add module mapping
10. Request path: *.cgi
11. Module: CgiModule
12. Name: dot.cgi
Now you can go to open welcome page and start navigate :http://"ServerName"/Cognos8

Warning: do not add cgi as MIME type

Data Governance Learning Plan

Seven courses to build the knowledge of Data Governance Program ( planning & establishment ) by Kelle O'Neal with 100 MCQs Exam 1....