SQL Server – Reset auto number (IDENTITY) column in SQL Server

How to reset auto number (IDENTITY) column in SQL Server? Sometimes we need to reset the auto number – identity column in a table. Using the DELETE statement is not enough. The statement only deletes the data but not reset the identity column. We can reset the auto number (IDENTITY) column in SQL Server using DBCC CHECKIDENT command. Following example shows how to reset auto number (IDENTITY) column the IDENTITY column Hope this post helps you.

» Read more

SQL Serevr Replication – Setup and configure Subscription on SQL 2008R2 – Part 4 of 4

New Subscription wizard as below Select the publication and then press “Next” Next you have choose the subscriber and subscription database Here we are choosing the Push subscription Select Push subscription (First one) then press “Next” Select Agent Schedule “Run Continuously” the press “Next” Select Initialize when as “At first Synchronization” Select option “Create the subscription” Wait for the subscription process to finish. Finally subscriber has been created. Reference URL http://varindersandhu.in/2011/08/12/sql-server-how-to-setup-sql-server-replication/

» Read more

SQL Serever Replication – Setup and configure the Publication on SQL Server 2000 – Part 3 of 4

In part 2, we have configured a SQL Server as a main publishing server, we have to create a publication of databases which the clients can subscribe. Click on New Publication “Create Publication Wizard” starts, check the “Show advanced options in this Wizard” checkbox and press “Next” After please select your database and press “Next” In the “Select Publication Type” screen select “Transactional publication” (second option) en press “Next” On the “Specify Articles” Screen check all the checkboxes on the

» Read more

SQL Server Replication – Setup and configure a SQL Server 2000 as a main Publisher/Distributor – Part 2 of 4

Click on the Configuring Publishing, subscribes and Distribution option then the Configuring Publishing and Distribution Wizard starts up. Specify the UNC (Universal Naming Convention) path Select “No”- accepting default settings – and press next. Successfully enabled…” message should appear. Notification that a “replication object” has been added to the console tree for this server in SQL Server Enterprise Manager Close this screen and the following SQL Server properties screen. Now you can see the Publisher in SQL Server Enterprise Manager

» Read more

SQL Server Replication – Configure the SQL Server Agent – Part 1 of 4

Once you are going setup SQL Server Replication configures the SQL Server Agent as: Make Sure SQL Server Agent is running Right click My Computer -> Manage… -> Choose from the tree at the left: “Services and Applications” -> “Services” By default the SQL Server Agent runs under the local System account, but for SQL Server Replication to work this must be changed to a specific created user account that has all the necessary rights to run as a service.

» Read more

SQL Server – How to Setup SQL Server Replication – Part 0 of 4

Introduction This document describes a scenario how to setup the Transactional SQL Server Replication. Before we proceed for Replication setup you can read brief note about “Understanding of Replication” http://varindersandhu.in/2011/05/14/understanding-of-replication/ Here we will setup the Transactional SQL Server Replication between SQL Server 2000 and SQL Server 2008R2. Pre-requisite SQL Server 2000 SQL Server 2008R2 This document describes below points Configure the SQL Server Agent Setup and configure a SQL Server 2000 as a main Publisher/Distributor Setup and configure the Publication

» Read more

SQL Server – Location of Installation Log file

A few times we were trying to locate the installation log file folder if we faced any issue or problem while installation of SQL Server. Basically, we want to know reason of issue or problem. So location of Log file folder as below SQL Server 2008 and 2008 R2 %programfiles%\Microsoft SQL Server\100\Setup Bootstrap\Log\ SQL Server 2005 %ProgramFiles%\Microsoft SQL Server\90\Setup Bootstrap\LOG\ You can find the Summary.txt file in above mentioned location. This file shows the SQL Server components that were detected during

» Read more

SQL Server – Error Handling Using TRY…CATCH

Prior to SQL server 2005, the only way of performing the error handling was to test vale of @@ERROR global variable. Once the SQL Server completes the execution of a Transact-SQL statement, it records the status of result in @@ERROR. If the error occurred, @@ERROR contains the error number. If the statement executed successfully it contain the 0. You need to check the variable if the statement succeeded or failed. Using @@ERROR to perform the error handling is not easy

» Read more

Restore SQL 2008 full database backup to SQL Server 2005

My friend wants to restore the SQL 2008 full backup to SQL Server 2005. He faced an issue while restore the SQL 2008 full backup to SQL Server 2005. He has a question from me as: Can we restore the SQL 2008 full database backup to SQL Server 2005? Answer: No, we can’t restore a backup from a higher version of SQL Server on a lower version of SQL Server. Alternative: If you are not using any features specific to

» Read more

SQL Server – Get Comma Separated Values from table

I had requirement to get the Comma Separated Values from the table for specific column. So here sharing with you example how i handle this situation. USE tempdb GO CREATE TABLE test1 ( column1 INT, column2 VARCHAR(6) ) INSERT INTO test1 VALUES (1,'Test1'), (1,'Test2'), (2,'Test3'), (2,'Test4'), (3,'Test5') Now see the table SELECT * FROM TEST1  Create a function to get the Comma Separated Values as below CREATE FUNCTION dbo.CommaSeparatedvalues ( @parameter1 AS INT ) RETURNS VARCHAR(5000) AS BEGIN DECLARE @CSV

» Read more

SQL Server – Mirror Backup of databases

It is very common practice to create an exact copy of the database backup and store it to different places so that in case any emergency or misfortune, DBA should have the alternative location to find the backup of databases.  Once a full backup is accomplished DBAs generally copy the database to another location in their network using utility tools like R-sync or native DOS commands like xcopy etc. Mirroring a media set increases backup reliability by reducing the impact

» Read more

Find the List of the SQL Servers running on a network

I had requirement to find list of all the SQL Server installed on local network then I found few very useful commands. Here sharing with you all. You can use sqlcmd, osql and isql with the -L option as shown below. Using sqlcmd -L Servers: SQLServer1 SQLServer2\DBServer SQLServer3\ReportServer SQLServer4\SQLExpress SQLServer5 Using osql -L Servers: SQLServer1 SQLServer2\DBServer SQLServer3\ReportServer SQLServer4\SQLExpress SQLServer5 Using isql -L Locally configured servers: –None– Announced network servers: SQLServer1 SQLServer2 SQLServer3 SQLServer4 SQLServer5 Note: sqlcmd  and osql is able

» Read more
1 2 3 4 5 6