Saturday, May 01, 2010
SQL Server 2005 Service Pack 4
SQL Server 2008 Service Pack 1 ( SQL Server 2008 SP1 ) will be released by third quarter of the year 2010 ( Quarter 3 of 2010 ). It will be the last Service pack for the SQL Server 2005.
Source: Shared by the Microsoft SQL Server release services group manager.
Monday, April 26, 2010
Learn SQL Server 2008 for free
Microsoft makes it easier than ever to attend SQL Server 2008 training, at little to no cost, without any travel necessary.
It just needed a email account on hotmail or msn.
Subject matter includes:
· Database Administration
· Database architecture
· Database, programming and security.
Click the courses below to see full descriptions or visit Microsoft Learning to browse the course catalog
Sunday, April 25, 2010
DAC – Dedicated Administrator Connection
Use Command below to connect as DAC
SQLCMD -A |
It is on by Default for local server.
For remote(via network) enable it by running query below
sp_configure |
For Clusters, recommended to enable remote admin connections as no local DAC available
---- Query to Find if DAC - Dedicated Admin Connection used -----
select s1.session_id, s1.program_name,s1.host_name,t1.name from sys.tcp_endpoints t1 join on t1.endpoint_id = s1.endpoint_id where t1.name = --- End of the Query ----- |
--- Query to check the DAC ---- --- Scheduler_ID = 255 & Status = "VISIBLE ONLINE (DAC) --- select |
Usage:
when SQL Server hangs, SQL Server does not respond, when SQL Server does not accept new connection
- Use DAC sparingly for monitoring and Troubleshooting
- Connect to master database first
- Use lightweight queries.
- Not advised for long running queries like ( DBCC CHECKDB, DBREINDEX, INDEXDEFRAG )
Friday, April 23, 2010
Thursday, April 22, 2010
SQL Server Latest Service Pack and Security Hot fixes
Applies to | Version Range | Type | Description | Target Version | Release Date | Security Bulletins | KB | Download | |
SQL Server 2000 | Below 8.00.2039 | Service Pack | SQL Server 2000 SP4 | 8.00.2039 | 6-Jun-05 | ||||
SQL Server 2000 | 8.00.2039-8.00.2054 | GDR | SQL Server 2000 SP4 GDR | 8.00.2055 | 10-Feb-09 | ||||
SQL Server 2000 | 8.00.2148-8.00.2281 | QFE | SQL Server 2000 SP4 QFE | 8.00.2282 | 10-Feb-09 | ||||
SQL Server 2005 | Below 9.00.4035 | Service Pack | SQL Server 2005 SP3 | 9.00.4035 | 15-Dec-08 | N/A | |||
SQL Server 2005 | 9.00.4035-9.00.4052 | GDR | SQL Server 2005 SP3 GDR | 9.00.4053 | 12-Oct-09 | ||||
SQL Server 2005 | 9.00.4205-9.00.4261 | QFE | SQL Server 2005 SP3 QFE | 9.00.4262 | 12-Oct-09 | ||||
SQL Server 2008 | Below 10.00.2531 | Service Pack | SQL Server 2008 SP1 | 10.00.2531.00 | 27-Aug-09 | N/A |
| ||
It lists only the latest SQL Server Service Pack and Security Hot fixes as on 22nd April 2010 | |||||||||
Software Asset Management - SAM
Software Inventory Assistance
Whether we have just a few computers or a large network, a software inventory tool can make it easier to quickly know what we have and how it's being used.
The Microsoft Software Inventory Analyzer (MSIA) is a free tool available for download that can help us with our software inventory. It is built specifically to be a starting point to working with SAM.
We can use the MSIA to scan and inventory the Microsoft software that is installed on a single computer, or on multiple computers throughout a network. It generates a report that provides details of all installed Microsoft products, including the type and the number of licenses. The MSIA will work with networks that have 250 or fewer computers. The latest MSIA 5.1 features enable you to:
- Identify and report all installed Microsoft products listed under Add or Remove Programs.
- Consolidate the MSIA report with the Microsoft Licensing Statement (MLS) report (.xls only).
This information is useful for you, if you are taking care of the system administration, licensing and inventory of Microsoft software products in your organization.
BgInfo
BgInfo – Microsoft Windows SysInternal tool
How many times have you walked up to a system in your office and needed to click through several diagnostic windows to remind yourself of important aspects of its configuration, such as its name, IP address, or operating system version If you manage multiple computers you probably need BGInfo. It automatically displays relevant information about a Windows computer on the desktop's background, such as the computer name, IP address, service pack version, and more. You can edit any field as well as the font and background colors, and can place it in your startup folder so that it runs every boot, or even configure it to display as the background for the logon screen.
Wednesday, April 21, 2010
SQL Server 2005/ 2008 Query to find when the database last used
Below is the TSQL Query to find when the database last accessed for SQL Server 2005 / 2008
-- Query to find when the database last accessed on SQL Server 2005 / 2008 --- select d.name, x1 = (select X1= max(bb.xx) from ( select xx = max(last_user_seek) where max(last_user_seek) is not null union all select xx = max(last_user_scan) where max(last_user_scan) is not null union all select xx = max(last_user_lookup) where max(last_user_lookup) is not null union all select xx = max(last_user_update) where max(last_user_update) is not null) bb) FROM master.dbo.sysdatabases d left outer join sys.dm_db_index_usage_stats s on d.dbid= s.database_id group by d.name |
Differentiate your connections to SQL Instances by coloring it
What would be the case. have you ever connected to a server, thought it was a testing or development system, and only a split second after you pressed "F5" to run that command, realized that it was the production server? Yeah….me neither :).
To make sure that's never you, when you start SQL Server 2008 Management Studio (SSMS), stop for a moment on the connection dialog and press "Options". You'll see that you can select a color for the connection – I set mine to red for production servers, yellow for testing servers, and green for development servers.
Once inside SSMS, you can also set the default color for all connections – I do this and set them all to red, so that if I forget, at least I'll have that visual indicator to make sure the change I'm making is on the right server.
It helps on classifying the SQL Server Instances by Production, Development, Test or QA etc.
Tuesday, April 20, 2010
Format Date or Time without “/”
Format the date or time without dividing characters, as well as concatenate the date and time string:
Sample statement | Output |
select replace(convert(varchar, getdate(),111),'/','') | 20100413 |
select replace(convert(varchar, getdate(),101),'/','') + replace(convert(varchar, getdate(),108),':','') | 20100413 004426 |
Select cast(int, convert(char,getdate(),111)) | 20100413 |
Monday, April 19, 2010
Remote Desktop Error - The terminal server has exceeded the maximum number of allowed connections
When trying to connect using a remote desktop session you may get this Login Failure Message, because there are too many remote sessions
To resolve the exceeded connection issue execute "mstsc /admin" ( mstsc /console )command from the command prompt as shown below
If a terminal server has exceed the maximum number of sessions an "/admin" session can still be created and this will allow you to still connect to the server.
The /admin sessions don't count towards the session limit that may be configured on a terminal server to limit the number of remote sessions, so this will give you a back door into the server if you get the message "The terminal server has exceeded the maximum number of allows connections".
Monday, April 12, 2010
SQL Server - Patching : An Incremental Servicing Model is available from the SQL Server team to deliver hotfixes for reported problems
The SQL Server team is moving away from the current priority-driven hotfix release model to a scheduled delivery model. In the scheduled delivery model, a customer can receive a hotfix to address their most critical situations with a short turn-around time. Additionally, a customer can receive a fix that has undergone more testing and that is released on a schedule basis. Therefore, the SQL Server team has created the following delivery mechanisms.
Critical On Demand - COD | On Demand- OD | Cumulative Update - CU | General Distribution Release - GDR |
The hotfix is released on or before a mutually agreed upon date based on the customer's need | The hotfix is released on or before a mutually agreed upon date based on the customer's need | The update is released every 2 months. | A GDR addresses an issue that has a broad customer impact, that has security implications, or that has both. A GDR is determined and issued by Microsoft as appropriate and when appropriate. GDRs are kept to a minimum. |
It contains all previous critical on-demand hotfixes to date. |
ISM eliminates the need for hotfix rollup releases. The first CU after a new release contains the hotfix rollup, plus any additional QFEs.
A hotfix package does not replace a service pack. A hotfix package is optional. A hotfix package can be installed or uninstalled at any time. Additionally, hotfix packages are cumulative. Therefore, the latest OD hotfix package or CU hotfix package includes all previously released hotfixes.
Quick Fix Engineering - QFEs are used for the majority of fixes where the effects of the problem are not widespread or severe enough to warrant a GDR.
Monday, February 08, 2010
Can we have database on SIMPLE Recovery model for Transactional Replication?
Yes. We can have Publisher database on SIMPLE recovery model.
The reason is that;
- When executing, the Log Reader Agent first reads the publication transaction log and identifies any INSERT, UPDATE, and DELETE statements, or other modifications made to the data transactions that have been marked for replication. Next, the agent batch copies those transactions to the distribution database at the Distributor.
- The Log Reader Agent uses the internal stored procedure sp_replcmds to get the next set of commands marked for replication from the log. The distribution database then becomes the store-and-forward queue from which changes are sent to Subscribers. Only committed transactions are sent to the distribution database.
- Only committed transactions are sent to the distribution database by LogReader agent.
- After the entire batch of transactions has been written successfully to the distribution database, it is committed. Following the commit of each batch of commands to the Distributor, the Log Reader Agent calls sp_repldone to mark where replication was last completed.
- Finally, the agent marks the rows in the transaction log that are ready to be truncated. Rows still waiting to be replicated are not truncated
- The transaction log on the Publisher can be dumped without interfering with replication, because only transactions not marked for replication are purged.
Thursday, January 14, 2010
SQL Server 2005 Cluster: SQL Server Service not coming online, error on TCP port is already in use
SQL Server Error Log:
2010-06-04 15:19:37.520 Server Server is listening on [ 10.0.0.136 <ipv4> 2813].
2010-06-04 15:19:37.530 Server Error: 26023, Severity: 16, State: 1.
2010-06-04 15:19:37.530 Server Server TCP provider failed to listen on [ 10.0.0.136 <ipv4> 2813]. Tcp port is already in use.
2010-06-04 15:19:37.530 Server Error: 17182, Severity: 16, State: 1.
2010-06-04 15:19:37.530 Server TDSSNIClient initialization failed with error 0x2740, status code 0xa.
2010-06-04 15:19:37.530 Server Error: 17182, Severity: 16, State: 1.
2010-06-04 15:19:37.530 Server TDSSNIClient initialization failed with error 0x2740, status code 0x1.
2010-06-04 15:19:37.530 Server Error: 17826, Severity: 18, State: 3.
2010-06-04 15:19:37.530 Server Could not start the network library because of an internal error in the network library. To determine the cause, review the errors immediately preceding this one in the error log.
2010-06-04 15:19:37.530 Server Error: 17120, Severity: 16, State: 1.
2010-06-04 15:19:37.530 Server SQL Server could not spawn FRunCM thread. Check the SQL Server error log and the Windows event logs for information about possible related problems.
Event Viewer Error
Event Type: Error
Event Source: MSSQL$PROD2K5ISD
Event Category: (2)
Event ID: 26023
Date: 4/06/2010
Time: 2:51:31 PM
User: N/A
Computer: PROD2K5ISD
Description:
Server TCP provider failed to listen on [ 10.0.0.136 <ipv4> 2813]. Tcp port is already in use.
Resolution
Monday, January 11, 2010
SQL Server 2005 /2008 Express Edition Backup automation
SQL Database Backup Script
| declare @IDENT INT, @sql varchar(1000), @DBNAME VARCHAR(200)
select @IDENT=min(DBID) while @IDENT is begin SELECT @DBNAME = NAME FROM /*Change disk location here as required*/ SELECT @SQL = PRINT @SQL EXEC (@SQL) select @IDENT=min(DBID) end |
DOS Batch files to backup the databases
| @echo off c: if not exist c:\SQLBackup\Logs MD C:\SQLbackup\Logs if not exist c:\SQLBackup\Backup MD C:\SQLbackup\Backup cd c:\SQLBackup Echo Backup Started >> c:\SQLBackup\Logs\SQLBAckup.log Date /T > c:\SQLBackup\Logs\SQLBAckup.log Time /T >> c:\SQLBackup\Logs\SQLBAckup.log Echo. echo *************************************************************************** >> c:\SQLBackup\Logs\SQLBAckup.log isql -S (local)\Express -E -i c:\sqlbackup\backup.sql >> c:\SQLBackup\Logs\SQLBAckup.log echo *************************************************************************** >> c:\SQLBackup\Logs\SQLBAckup.log echo. Date /T >> c:\SQLBackup\Logs\SQLBAckup.log Time /T >> c:\SQLBackup\Logs\SQLBAckup.log echo Backup Finished >> c:\SQLBackup\Logs\SQLBAckup.log echo. echo *************************************************************************** >> c:\SQLBackup\Logs\SQLBAckup.log |
Folders will look like,
Schedule it on Windows Task Scheduler
That's it the SQL Server 2005 / 2008 Express Edition database backup is automated now!
Sunday, December 13, 2009
SQL Server Lever collation change
2. If applicable, backup DTS packages, Jobs, SSIS packages, mailing profiles or other objects installed by the application.
3. Script/take screenshot of logins with level of access on server level as well as the database level, user objects for example - tables, functions, types and stored procs, extended stored procs, if any on model or master db.
4. Detach all the user databases.
5. Rebuild the master database specifying the new collation in the SQLCOLLATION property of the setup command. For example:
start /wait setup.exe /qb INSTANCENAME=MSSQLSERVER REINSTALL=SQL_Engine REBUILDDATABASE=1 SAPWD=test SQLCOLLATION=SQL_Latin1_General_CP1_CI_AI
6. Check the tempdb collation and it should be ?Latin1_General_CI_AS? create users with help of screenshot/Script and restore user objects from step 3. Run scripts for functions and types if any.
7. Attach user databases from step 4 / Restore all the databases from the backup from step 1 and all the objects from the backup taken in step1. Refer client mail for further clarifications.
Wednesday, November 25, 2009
Error message when you open SQL Server Configuration Manager in SQL Server 2008: "Cannot connect to WMI provider. You do not have permission or the se
"Cannot connect to WMI provider. You do not have permission or the server is unreachable"
Cause:
This problem occurs because the WMI provider is removed when you uninstall an instance of SQL Server 2008. The 32-bit instance and the 64-bit instance of SQL Server 2008 share the same WMI configuration file. This file is located in the %programfiles(x86)% folder.
Workaround:
To work around this problem, type the following command, and then press ENTER:
mofcomp "%programfiles(x86)%\Microsoft\Microsoft SQL Server\100\Shared\sqlmgmproviderxpsp2up.mof"
Refer the KB# 956013
Tuesday, November 24, 2009
The SQL Server Service Broker or Database Mirroring transport is disabled or not configured
The Service Broker is enabled by default in SQL Server 2005. Service Broker is enabled by default when a new database is created. Please try to run the following query to see the Broker option on a database.
SELECT name, is_broker_enabled FROM sys.databases;
This alert is triggered by event 9666 in the Application Event log for the OpsMgr database server.However, this event is always generated when you restart SQL because neither the Service Broker nor Database Mirroring are enabled for the Master or
Model databases. "SELECT is_broker_enabled FROM sys.databases" identifies
that the Service Broker is enabled for all other DBs. The alert is a bit counter productive if the rule is there to try to identify which databases are missing this option that actually need it; e.g. the OpsMgr db.Currently my only option is to disable the rule.
Monday, November 23, 2009
How to Script Database Schema
2. Select Tasks --> Generate Scripts
3. Select all the objects in the selected databases
4. Select the appropriate General & Table Options
5. Select the output format
Thursday, November 19, 2009
Testing a Connection from Client to SQL Server using UDL
Step 1 - Create a .udl file
Create a text file and name it for example test.udl
Double click on test.udl to open the connection dialog.
Step 2 - Choose the type of connection
Go to the first tab “Provider”
Choose “Microsoft OLE DB Provider for SQL Server” or any other provider according to your needs.
Step 3 - Set up connection properties
Go to the second tab “Connection”, choose the server, enter username/password and choose a database from the drop down list.
Step 4 - Connection String
Once you click on “OK” a connection string based on your connection settings is written to test.udl. After you open test.udl you will find a connection string like this.
[oledb]; Everything after this line is an OLE DB initstringProvider=SQLOLEDB.1;Password=wrf%32g;Persist Security Info=True;User ID=siva;Initial Catalog=msdb;Data Source=SQLTEST