Archive for the ‘DB Articles’ Category

How to Create Alias in SQL Server?

Posted by Jugal Shah on January 7, 2011

What is Alias?
A SQL Server alias is the user friendly name. For example if there are many application databases hosted on same SQL Server. You can give the different alias name for each application. Simply Alias is an entry in a hosts file, a sort of hard coded DNS lookup a SQL Server instance.

You can create Alias from Configuration Manager.

Go to SQL Server Configuration manager – Go to SQL Native Client -> Right Click and SELECT New Alias from the popup window.

Alias Name — Alernative name of SQL Server
Port No — Specify the Port No
Server – Mentioned the Server Name or IP address

Make sure On a 64-bit system, if you have both 32-bit and 64-bit clients, you will need to create an alias for BOTH 32-bit and 64-bit clients.

Posted in Database, DB Articles, SQL Server, SQL Server 2008, SQL Server 2008 R2 | Tagged: | Leave a Comment »

Backup Start Date Time and Finish Date Time

Posted by Jugal Shah on January 3, 2011

As best practice it is recommended that you have to backup date time with the backup file name so anyone can get the idea of Backup creation.

Sometimes due some issue we took backup without specifying the datetime with the backup file name so during restore we are unsure that how much data backed up in the backup file, type of backup, Is it Copy only and more.

SQL Server stores the Backup Metadata into backup header. You can restore header only command to get the required information.

RESTORE headeronly FROM disk = ‘c:\jshah.bak’ 

Column Name Values Description
BackupName NULL  
BackupDescription NULL  
BackupType 1 Backup type:
1 = Database
2 = Transaction log
4 = File
5 = Differential database
6 = Differential file
7 = Partial
8 = Differential partial
ExpirationDate NULL  
Compressed 0 0 = Un-Compressed Backup
1 = Compressed Backup
Position 1  
DeviceType 2  
UserName JShah  
ServerName SQLDBPool  
DatabaseName jshah  
DatabaseVersion 655  
DatabaseCreationDate 12/31/10 9:55 AM  
BackupSize 1453056  
FirstLSN 28000000006000100  
LastLSN 28000000013000000  
CheckpointLSN 28000000006000100  
DatabaseBackupLSN 0  
BackupStartDate 12/31/10 10:06 AM  
BackupFinishDate 12/31/10 10:06 AM  
SortOrder 52  
CodePage 0  
UnicodeLocaleId 1033  
UnicodeComparisonStyle 196609  
CompatibilityLevel 100  
SoftwareVendorId 4608  
SoftwareVersionMajor 10  
SoftwareVersionMinor 0  
SoftwareVersionBuild 2757  
MachineName SQLDBPool  
Flags 512 1 = Log backup contains bulk-logged operations.
2 = Snapshot backup.
4 = Database was read-only when backed up.
8 = Database was in single-user mode when backed up.
16 = Backup contains backup checksums.
32 = Database was damaged when backed up, but the backup operation was requested to continue despite errors.
64 = Tail log backup.
128 = Tail log backup with incomplete metadata.
256 = Tail log backup with NORECOVERY.
BindingID 85A5505D-ADB1-4B33-A181-549DC520A0F8  
RecoveryForkID 03DE5437-1E27-4885-9011-91CFED12338A  
Collation SQL_Latin1_General_CP1_CI_AS  
FamilyGUID 03DE5437-1E27-4885-9011-91CFED12338A  
HasBulkLoggedData 0 1 = Yes
0 = No
IsSnapshot 0 1 = Yes
0 = No
IsReadOnly 0 1 = Yes
0 = No
IsSingleUser 0 1 = Yes
0 = No
HasBackupChecksums 0 1 = Yes
0 = No
IsDamaged 0 1 = Yes
0 = No
BeginsLogChain 0 1 = Yes
0 = No
HasIncompleteMetaData 0 1 = Yes
0 = No
IsForceOffline 0 1 = Yes
0 = No
IsCopyOnly 0 1 = Yes
0 = No
FirstRecoveryForkID 03DE5437-1E27-4885-9011-91CFED12338A  
ForkPointLSN NULL  
RecoveryModel FULL  
DifferentialBaseLSN NULL  
DifferentialBaseGUID NULL  
BackupTypeDescription Database  
BackupSetGUID 62EB4399-C119-42C2-91F1-BF0FF19CB896  
CompressedBackupSize 1453056  

Posted in Database, DB Articles, SQL Scripts, SQL Server, SQL Server 2008, SQL Server 2008 R2 | Tagged: | 2 Comments »

How to check database ISOLATION Level?

Posted by Jugal Shah on October 29, 2010

You can use below query to check the database isolation level.

DBCC UserOptions

Posted in DB Articles, SQL Server | Leave a Comment »

How to move Cluster Resource/Services to proper node using command prompt?

Posted by Jugal Shah on October 5, 2009

cluster group “SQL Server Group” /move: Physical_Name_Of_Node1

cluster group “SQL Server Group INST2″ /move: Physical_Name_Of_Node2

Posted in DB Articles | Tagged: | Leave a Comment »

Happy Birthday to Me (It’s 1-Sept)

Posted by Jugal Shah on September 1, 2009

happybirthdaytome

Posted in DB Articles | 1 Comment »

Server: Msg 7391, Level 16, State 1, Line 2

Posted by Jugal Shah on July 22, 2009

Problem Symtomps
The operation could not be performed because the OLE DB provider ‘SQLOLEDB’ was unable to begin a distributed transaction. OLE/DB provider returned message: New transaction cannot enlist in the specified transaction coordinator.

Cause
The problem occurs because Microsoft Distributed Transaction Coordinator (MS DTC) is not configured for network access. By default, the network access settings of MS DTC are disabled on new installations of SQL Server 2000 on computers that are running Windows Server 2003.
Resolution

Step 1: Open Component Services Wizard using below steps
Go to -> Start -> All Programs -> Administrative Tools -> Component Services

Step 2: Expand the Componenet Service and Double Click on Computers

Step 3: Right Click on MyCompute and select properties

Step 4: Click on MSDTC Tab and then click on Security Configuration

Step 5: In the Security Configuration dialog box, check the Network DTC Access check box

Step 6: Under  Network DTC Access, click on New transaction

 Please find the below images for the same.

untitled1

Figure 2

Select Network Transaction

Figure 3

untitled3

Posted in DB Articles | Leave a Comment »

Insert Extended Character using OSQL Utility

Posted by Jugal Shah on July 22, 2009

Problem: OSQL utility uses ODBC to communicate with the server. User’s problem is that the ODBC driver he is using to connect to the database is performing translations on the character data in the T-SQL script. Extended characters, which are not in the standard ASCII character set, are translated by the driver based on drive settings. The character translation option is ON by default when SQL Server executes scripts through the OSQL utility. 

Below query is inserting garbage data in the table. 

CREATE TABLE #temp(col1 varchar(40) NOT NULL )

INSERT INTO #temp VALUES( ‘Tëst’ )

SELECT col1 FROM #temp

DROP TABLE #temp 

Solution: By using Unicode script files and converting the column to Unicode, user can avoid the character translation. For that user needs to add N against the column, which is already added. 

Save As below script file as UNICODE file 

CREATE TABLE #temp(col1 varchar(40) NOT NULL )

INSERT INTO #temp VALUES( ‘Tëst’ )

SELECT col1 FROM #temp

DROP TABLE #temp 

User needs to do the following with the ODBC DSN to execute the scripts successfully, without any translation:

1.    Create an ODBC system data source called MyDSN on the machine where he is executing OSQL with the “Perform translation for character data” option cleared

2.    Specify this data source name as a parameter to OSQL so that OSQL can read the DSN settings and use them upon connection to SQL Server. 

osql -S. -itest.sql –DMyDSN

OR

User needs to develop a script which can pass the ASCII value 

Select ASCII(‘ë’)

INSERT INTO #temp (Col1) Select ‘T’ + chr(233) +  ’st’

Posted in DB Articles | Tagged: | Leave a Comment »

How to improve communication skills & Support Service

Posted by Jugal Shah on July 16, 2009

As DBA comes under the support industry, it is extremely important for DBAs to improve communication skills. As we are working production servers and backend, it is extremely important for us to communicate properly. 

  • Please take care of the below points to improve your written communication skill. 
  •  When you reply all, make sure to move names from TO to CC and CC to TO list according to whom you are writing emails
  • Be concise and to the point. Use simple English.
  • Avoid the use of slang words/abbreviations
  • Use proper spelling, grammar & punctuation
  • Do not write in CAPITALS. CAPITALS indicate that we are shouting.
  • Numbers should be expressed as words when the number is less than 10 or is used to start a sentence (example: Ten years ago, my brother and I…). The number 10, or anything greater than 10, should be expressed as a figure (example: My brother has 13 Matchbox cars.)
  • You should just mention the name instead of Hi Jugal.As we are working as support team, use `We` instead of `I`. For example; Jugal instead of Hi Jugal
  • You should change the text in the Subject line during reply emails if it is not relevant.
  • If you are asking for something in the email, you should ask them first and then mention why you need that.
  • Don’t write open ended email to user
  • If you are not sure for any support request, please ask end user for more inputs on particular request.
  • Inform your team regarding any conversation with client through chat or voice call
  • Update your work log every day
  • If you are not sure for any resolution steps, discuss it with your team and then provide it to client
  • When sending large attachments, always “zip” or compress them before sending.
  • Always include subject in your mail body.
  • Don’t send email to any account using your client account
  • Discuss as much as possible with your client
  • Grab as much as possible knowledge of the client process/environment

Posted in DB Articles | Tagged: , | Leave a Comment »

Save Water, Save Life and Save the Workl

Posted by Jugal Shah on June 27, 2009

Poster_lrg_Save-Water-save-

Posted in DB Articles | 1 Comment »

Troubleshoot Suspect Database Issue

Posted by Jugal Shah on June 25, 2009

Problem

How to troubleshoot suspect database problem? How to bring it back online? What are the do you need to perform once the database is online?

Solution

Step 1: Bring the database online using below script

USE Master

GO

 

– Determine the original database status

SELECT [Name], DBID, Status

FROM master.dbo.sysdatabases

GO

 

– Enable system changes

sp_configure ‘allow updates’,1

GO

RECONFIGURE WITH OVERRIDE

GO

 

– Update the database status

UPDATE master.dbo.sysdatabases

SET Status = 24

WHERE [Name] = ‘SuspectedDatabaseName’

GO

 

– Disable system changes

sp_configure ‘allow updates’,0

GO

RECONFIGURE WITH OVERRIDE

GO

 

– Determine the final database status

SELECT [Name], DBID, Status

FROM master.dbo.sysdatabases

GO

Step 2: Check for database corruption. This is very important step please execute it.

  • DBCC CHECKDB – Validate the overall database integrity
  • DBCC CHECKCATALOG – Validate the system catalog integrity
  • DBCC CHECKTABLE – Validate the integrity for a single table

Step 3: To resolve the corruption issue, please execute below commands

  • Drop and Recreate Index(es)
  • Move the recoverable data from an existing table to a new table
  • Update statistics
  • DBCC UPDATEUSAGE
  • sp_recompile

Step 4: Repeat Step 2 to validate all the corruption occurred

Posted in DB Articles | Leave a Comment »

DRBD, Heartbeat and MySQL

Posted by Jugal Shah on June 23, 2009

The easiest solution to implement clustering in MySQL is DRBD and Heartbeat.

DRBD: The Distributed Replicated Block Device (DRBD) is a software-based, shared-nothing, replicated storage solution mirroring the content of block devices (hard disks, partitions, logical volumes etc.) between servers.

DRBD mirrors data

  • In real time. Replication occurs continuously, while applications modify the data on the device.
  • Transparently. The applications that store their data on the mirrored device are oblivious of the fact that the data is in fact stored on several computers.
  • Synchronously or asynchronously. With synchronous mirroring, a writing application is notified of write completion only after the write has been carried out on both computer systems. Asynchronous mirroring means the writing application is notified of write completion when the write has completed locally, but before the write has propagated to the peer system

You can download DRDB from below site

http://www.drbd.org/download/packages/

Posted in DB Articles | Leave a Comment »

 
Follow

Get every new post delivered to your Inbox.

Join 174 other followers