In this blog you will find various tools and articles that are useful to any DBAs. I will try to put more practical articles while at the same time post any database software bugs and some important tips on internals of sql server and optimization. Address cons and pros of different relational database management in use and new developments. This blog will also cover the market perception of different database system including some hard facts, reviews and benchmarks. Teshome Asfaw
Tuesday, October 30, 2007
SQL Server Survival Guide
From time to time I refer to this sql server servival guide and would like to share with you. It focuses on SQL server 2000. For more details click SQL Server Survival Guide
Monday, October 29, 2007
Transactional replication optimisation
The following article from microsoft is a good starting point on how to optimise Transactional replication. Click the link for more info.Transactional replication Optimisation
Monday, October 08, 2007
Query replicated articles
Query replicated articles
If you are using an environment where there many publications and subscriptions it is difficult to find out the list of articles for particular subscriber.
The following code uses system tables in distribution to accomplish the task.
This query will retrieve publisher, publication, subscriber database, subsriber_id
select distinct pub.Publisher_db,pub.Publication, sub.subscriber_db,
sub.subscriber_id,art.article, art.destination_object from
distrib_.dbo.MSsubscriptions sub
join.dbo.MSPublications pub
on sub.Publication_id = pub.Publication_id
join.dbo.MSArticles art
on art.publication_id = pub.publication_id
where sub.subscriber_id = [subsriber_id]
If you have multiple distribution databases on the same server you can use union all with pre-fix of database name.
If you are using an environment where there many publications and subscriptions it is difficult to find out the list of articles for particular subscriber.
The following code uses system tables in distribution to accomplish the task.
This query will retrieve publisher, publication, subscriber database, subsriber_id
select distinct pub.Publisher_db,pub.Publication, sub.subscriber_db,
sub.subscriber_id,art.article, art.destination_object from
distrib_
join
on sub.Publication_id = pub.Publication_id
join
on art.publication_id = pub.publication_id
where sub.subscriber_id = [subsriber_id]
If you have multiple distribution databases on the same server you can use union all with pre-fix of database name.
Tuesday, October 02, 2007
Removing registered servers
From time to time your registered servers will get out of date for example if the server is de-commissioned or the instance is removed. Using Enterprise manager some times frustrating. The easiest way to remove your registered server is by removing it from registry. The following step will help you how to do this.
a. Go to start menu and click run
b. Enter Regedit and click Ok
c. The registery editor will come up
d. Click on HK_Users and go to edit menu and click find
e. Type in Registered Servers X
f. Find the registered server from the list and delete
a. Go to start menu and click run
b. Enter Regedit and click Ok
c. The registery editor will come up
d. Click on HK_Users and go to edit menu and click find
e. Type in Registered Servers X
f. Find the registered server from the list and delete
Tuesday, September 18, 2007
Adding the article's partition column(s)
Procedure to add articles partition column
exec sp_articlecolumn
@publication = N'PublicationName', @article = N'ArticleName', @column = N'ColumnName', @operation = N'add'
GO
exec sp_articlecolumn
@publication = N'PublicationName', @article = N'ArticleName', @column = N'ColumnName', @operation = N'add'
GO
Thursday, September 13, 2007
Windows & SQL cluster
The following are usefull links if you are planning to do Windows & SQL cluster clustering project.
- Troubleshooting cluster node installations
- Designing and Deploying Clusters
- latest information about windows 2003
- Quorum Drive Configuration Information
- Recommended private 'Heartbeat' configuration on a cluster server
- Network Failure Detection and Recovery in a Server Cluster
-How to Change Quorum Disk Designation
- Server Clusters : Storage Area Networks
- Troubleshooting cluster node installations
- Designing and Deploying Clusters
- latest information about windows 2003
- Quorum Drive Configuration Information
- Recommended private 'Heartbeat' configuration on a cluster server
- Network Failure Detection and Recovery in a Server Cluster
-How to Change Quorum Disk Designation
- Server Clusters : Storage Area Networks
Password expiration dates
I have various questions from different people asking me how to set password expiration in previous version of sql server (2000 and 7). While trying to find out a way of setting password expiration, I have come accross this article from microsoft.
To view details of how to do this click How to implement password expiration dates for SQL Server 2000 or SQL Server 7.0 login IDs.
To view details of how to do this click How to implement password expiration dates for SQL Server 2000 or SQL Server 7.0 login IDs.
Tuesday, July 31, 2007
Monday, July 09, 2007
Creating Deadlocks
I have have been trying to re-create deadlocks in my database and after a few try I came up with a scripts which does it for me.
CREATE TABLE createDeadlock1 (deadLockId int)
go
Create Table createDeadlock2 (deadlockId int)
-- now populate the table with some data
insert into createDeadlock1
values (1)
insert into createDeadlock2
values(1)
-- now open two connections
steps 1 : In connection 1 run :
begin tran
update createDeadlock1
set deadlockId = 1
step2 : Then in connection 2 run
begin tran
update createDeadlock2
set deadlockId = 1
update createDeadlock1
set deadlockId = 1
step 3 - go back to connection 1 and run
update createDeadlock2
set deadlockId = 1
The above three steps will create a deadlock. Do it many times and you will see the counter value always increasing. To view the counter use sysperfinfo table as shown below.
select * from master.dbo.sysperfinfo
where instance_name = '_total' and counter_name like '%deadlock%'
CREATE TABLE createDeadlock1 (deadLockId int)
go
Create Table createDeadlock2 (deadlockId int)
-- now populate the table with some data
insert into createDeadlock1
values (1)
insert into createDeadlock2
values(1)
-- now open two connections
steps 1 : In connection 1 run :
begin tran
update createDeadlock1
set deadlockId = 1
step2 : Then in connection 2 run
begin tran
update createDeadlock2
set deadlockId = 1
update createDeadlock1
set deadlockId = 1
step 3 - go back to connection 1 and run
update createDeadlock2
set deadlockId = 1
The above three steps will create a deadlock. Do it many times and you will see the counter value always increasing. To view the counter use sysperfinfo table as shown below.
select * from master.dbo.sysperfinfo
where instance_name = '_total' and counter_name like '%deadlock%'
Wednesday, July 04, 2007
sysperfinfo not time - adjusted
Recently, I come across a monitoring tool that uses sysperfinfo table to get out number of dead locks/second. It took me a good few minutes to figure out that using this value as a time – adjusted counter was wrong. I am not sure if it is by design or a bug in Microsoft that some of the counters are not time-adjusted. So, the values you are getting for this particular counter is an incremental value. While digging a bit into Microsoft knowledge base I came across an article written by Geoff Hiten (MVP) in February 25, 2004 and it has been reported as a bug. This shows that some of monitoring tools shows you wrong information. To view the article click sysperfinfo not time - adjusted. This article lists the counters that are affected.
Monday, June 25, 2007
SQL Server Katmai
MSDN Forums for Katmai - nice discussion going on. Click the link to participate: SQL Server Katmai
Thursday, June 14, 2007
Tables and their row counts
Implication of using different methods of getting Tables and thier row counts in SQL server database :
Tables and their row counts
Tables and their row counts
Wednesday, June 13, 2007
SQL Server 2008
Latest version of SQL Server 2008 CTP is out this june. More info on this version of SQL server can be found in SQL server 2008 CTP
Latest version of SQL server
To get an idea of what the latest version of SQL server will be, you can ask a SQL guru @Ask SQL Guru
Friday, May 04, 2007
Renaming a SQL Server
The following steps will help you in avoiding most of the issues that arise from renaming a SQL Server.
Open query analyser and to the following simple three steps
1. Drop the old server name (sp_dropserver 'old server name' )
2. Add new server name (sp_addserver 'new server name', 'local')
3. Update sysjobs table column that contain the original server name to new server name
Open query analyser and to the following simple three steps
1. Drop the old server name (sp_dropserver 'old server name' )
2. Add new server name (sp_addserver 'new server name', 'local')
3. Update sysjobs table column that contain the original server name to new server name
Friday, April 20, 2007
SQL server script library
Very useful SQL server script on SQL server central. For more info SQL server script library
Thursday, April 19, 2007
Enable output logging for a pull subscription
The following steps will help you in Enabling output logging for a pull subscription.
In SQL Enterprise Manager, click the Subscriber database.
2. Open the Pull Subscriptions folder.
3. In the right-hand pane of SQL Enterprise Manager you will see the pull subscription.
4. Open the subscription properties by double-clicking the subscription.
5. Click the General tab to open the agent properties dialog box. Click Distribution Agent Properties for a transactional pull subscription and click Merge Agent Properties for a merge pull subscription.
6. Click the Steps tab, and then edit the Run Agent step.
7. At the end of the string under command, add:
-Output C:\Temp\OUTPUTFILE.txt -Outputverboselevel [012]
Specify either 0, 1, or 2 after the -Outputverboselevel parameter.
8. Click OK to save the changes, and then close the Edit Job Step dialog box.
9. Click OK to save changes, and then close the Replication Agent Properties dialog box. If the agent is set to run continuously, stop and then restart the replication agent so that SQL Server logs the messages to the log file you specified in step 7. If file already exists, the agent appends the output to a file.
Source : http://www.microsoft.com
In SQL Enterprise Manager, click the Subscriber database.
2. Open the Pull Subscriptions folder.
3. In the right-hand pane of SQL Enterprise Manager you will see the pull subscription.
4. Open the subscription properties by double-clicking the subscription.
5. Click the General tab to open the agent properties dialog box. Click Distribution Agent Properties for a transactional pull subscription and click Merge Agent Properties for a merge pull subscription.
6. Click the Steps tab, and then edit the Run Agent step.
7. At the end of the string under command, add:
-Output C:\Temp\OUTPUTFILE.txt -Outputverboselevel [012]
Specify either 0, 1, or 2 after the -Outputverboselevel parameter.
8. Click OK to save the changes, and then close the Edit Job Step dialog box.
9. Click OK to save changes, and then close the Replication Agent Properties dialog box. If the agent is set to run continuously, stop and then restart the replication agent so that SQL Server logs the messages to the log file you specified in step 7. If file already exists, the agent appends the output to a file.
Source : http://www.microsoft.com
Monday, April 16, 2007
SQL Server Replication
Good article on how to setup SQL server replication over the internet. SQL Server Replication Across Domains and the Internet
Thursday, April 12, 2007
Pull subscription errors
The process could not read file '\\servername\replfolder\unc\_Data sch' due to OS error 1326. The step failed.
The work around can be found on microsoft support site. Click here to view Pull Subscription
The work around can be found on microsoft support site. Click here to view Pull Subscription
Wednesday, April 11, 2007
Mathematics for Database Professionals
Has anybody read this book? Click here Applied Mathematics for Database Professionals . Would like to hear your views.
Thursday, March 22, 2007
Column collation to Server Default
The following script will help you to change all columns in your database to server default collation. You can modify this script to do all your databases on particular server.
set nocount on
declare @AlterId int
declare @serverColl varchar(100)
declare @AlterString varchar(300)
set @serverColl = convert(sysname, serverproperty('collation'))
declare @Testing table
(AlterId int identity(1,1) not null primary key clustered,
AlterString varchar(300))
INSERT INTO @Testing(AlterString)
select 'ALTER TABLE [' + so.name + '] ' +
'ALTER COLUMN [' + sc.name + '] ' +
st.name +
'(' + cast(sc.length as varchar) + ') ' +
'COLLATE '+ @serverColl + ''
from syscolumns sc
join sysobjects so
on so.id = sc.id
join systypes st
on st.xtype = sc.xtype
where sc.collation is not null
and OBJECTPROPERTY(Object_id(so.name), 'IsTable') = 1
and st.name!= 'sysname'
and sc.collation not like @serverColl
select @AlterId = Max(AlterId) from @Testing
WHILE @AlterId IS NOT NULL
BEGIN
SELECT @AlterString = AlterString FROM @Testing
WHERE AlterId = @AlterId
EXEC (@AlterString)
SELECT @AlterId = Max(AlterId) from @Testing
WHERE AlterId < @AlterId
END
set nocount on
declare @AlterId int
declare @serverColl varchar(100)
declare @AlterString varchar(300)
set @serverColl = convert(sysname, serverproperty('collation'))
declare @Testing table
(AlterId int identity(1,1) not null primary key clustered,
AlterString varchar(300))
INSERT INTO @Testing(AlterString)
select 'ALTER TABLE [' + so.name + '] ' +
'ALTER COLUMN [' + sc.name + '] ' +
st.name +
'(' + cast(sc.length as varchar) + ') ' +
'COLLATE '+ @serverColl + ''
from syscolumns sc
join sysobjects so
on so.id = sc.id
join systypes st
on st.xtype = sc.xtype
where sc.collation is not null
and OBJECTPROPERTY(Object_id(so.name), 'IsTable') = 1
and st.name!= 'sysname'
and sc.collation not like @serverColl
select @AlterId = Max(AlterId) from @Testing
WHILE @AlterId IS NOT NULL
BEGIN
SELECT @AlterString = AlterString FROM @Testing
WHERE AlterId = @AlterId
EXEC (@AlterString)
SELECT @AlterId = Max(AlterId) from @Testing
WHERE AlterId < @AlterId
END
Wednesday, March 21, 2007
Renaming Database server
You may receive error 14274 - cannot update or delete job (or its steps or schedules) that originated from an MSX server. You can run the following script on MSDB database to correct:
update sysjobs
set originating_server = 'new serverName'
update sysjobs
set originating_server = 'new serverName'
Stored procedure tips
Have come across this Stored procedures in SQL Server: A dozen must-have tips. From tuning to how to perform cross tab queries. You can find by clicking this link Stored procedure tips
Sunday, March 18, 2007
Best practice analyser
I have just downloaded and played with the new SQL server 2005 best practice analyser (CTP). First impression is that much better than previous version. Will post more details in near future. For now you can download it from
http://www.microsoft.com/downloads/details.aspx?FamilyId=DA0531E4-E94C-4991-82FA-F0E3FBD05E63&displaylang=en and play with it
http://www.microsoft.com/downloads/details.aspx?FamilyId=DA0531E4-E94C-4991-82FA-F0E3FBD05E63&displaylang=en and play with it
Monday, March 12, 2007
All tables with identity
I thought the following script is useful if you want to find out all tables with identity columns in a specific database.
use
go
SELECT
DISTINCT TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE OBJECTPROPERTY(OBJECT_ID(TABLE_NAME), 'TableHasIdentity') = 1
AND TABLE_TYPE = 'BASE TABLE'
use
go
SELECT
DISTINCT TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE OBJECTPROPERTY(OBJECT_ID(TABLE_NAME), 'TableHasIdentity') = 1
AND TABLE_TYPE = 'BASE TABLE'
Thursday, February 15, 2007
Name value pair and Replication ?
Have you ever tried to design your database with the extreme end of using name value pair ? Name vaule pair if used in database design is like job done for ever. It sounds simple but in the next two parts, I will try to explain the benefits and the drawbacks of using named value pair in database design.
The secod part of the title is about replication. Is it good or bad ? I will also try to put together the advantages and disadvantages of using database replication in work environment.
So, watch out this page in the next two to four weeks.
Tesh
The secod part of the title is about replication. Is it good or bad ? I will also try to put together the advantages and disadvantages of using database replication in work environment.
So, watch out this page in the next two to four weeks.
Tesh
Subscribe to:
Posts (Atom)