Posts

Showing posts with the label sql server 2008

Connect Management Studio Data Base from Server Explorer of Visual Studio

Image
To day I show You how To connect SQL Management Studio from Server Explorer of Visual studio. I am always very Much Confuse to Connect Local DB in Visual Studio 2010 from Sql Management studio. But Now I search Alot and clear My Concepts and I also Want to Show these Concepts to you So can Also understand . STEPS First You Have to Open SQL Management Studio   It should be look like this Now Open Visual Studio And Create New Project (Asp.net Site or Windows Form Application) Open Server Explorer Window Server Explorer is known as Database Explorer in Visual Studio Express MSDN How to: Connect to a Database from Server Explorer Visual Studio 2010 comes with Server Explorer - which allows you to connect to a remote SQL Server database. View → Server Explorer → click the Connect to Database button on the top of the Server Explorer panel  From the View menu, choose Server Explorer. In Server Explorer right-click the Data Connections ...

How to reset the value of identity Column in SQL Server?

Image
Here’s a way to reset the value of the identity column in SQL Server . The scenario is explained below . For example , when the table “Customers” has an identity column with the initial value of 1 and seed 1 .Each time when you start an App and perform an operation , you might want to delete  all the records inside the table and perform the new inserts . ( Not the best of the methods , but the App had to do it ) . Now Each time I wanted to have the identity value start from 1 . The Delete statement alone is not enough to reset the identity value . After the Deletion of the records we should execute the DBCC command along with the CHECKIDENT switch along with the table name and the seed value . Like this DELETE   FROM  CUSTOMERS   DBCC CHECKIDENT (CUSTOMERS,RESEED, 0)   DELETE FROM CUSTOMERS DBCC CHECKIDENT (CUSTOMERS,RESEED, 0) Here comes a better approach , instead of using the DELETE and DBCC commands , the Truncate will do...