Sql Server

Row Number function in SQL Server

I used to create temporary tables and subqueries to add a row number to every row in the result set. But somedays ago, I came across to the Row_Number() function provided in Sql Server, which simply constructs the row number column on the fly as part of the query. But a question might have arosed in your mind, What is the use of adding a Row_Number, when we have serial number associated with every row. There are several situation, where we need to query against the row number.(we can't query against a serial number)

How to ReSeed Identity value in SQL Server?

I want to reset an identity coloumn in SqlServer. I am using

Delete from "TableName".

It is deleteing all data in the table but it is not resetting my Identity value.

I have tried Truncate Table , But I will not be able to restore my data back in case of truncate.

I need a method to delete all rows from the table and simultaneosly reset the identity value.

Index in Sql Server

Understanding Indexes

 

Indexes speed up the querying process by providing filtered access to rows in the data tables (just like book’s index) if they are used efficiently.

Indexes are created on columns in tables or views.

Set two variables using a Select query in a stored procedure.

SET @Password = ( 
    SELECT Value1,Value2
    FROM [dbo].[Table1]  
    WHERE [Expr1]) 

I am trying to get both values 'Value1' and 'Value2' in two variables to be used in same SP in next query. Is it possible or do I have to write two queries for this. Is it there a concept of arrays in sql server

SQL Server 2005 error 10061

I needed to connect to sql server from a remote computer which is on my home lan.
But got this error message.

AutoIncrement vs UniqueIdentifier

How to decide which key to used in your application? Whether to use AutoIncrement or UnqiueIdentifier.

Please tell me the different scenarios for using these keys.

SQL Server: Backup and Restore Database using T-SQL

Its very easy to take Backup and Restore your Database using T-SQL even if you are not a DBA. In one of the client application, I wanted to take periodic Backup without logging in to SQL Server Management Studio. Here in this small tutorial I will try to elaborate the procedure of taking database backup using T-SQL.

1. Create a Database

CREATE DATABASE PracticeDB

2. Take Backup of the Database

BACKUP DATABASE PracticeDB
TO DISK='C:\PracticeD.bak'
WITH DESCRIPTION='Database Backup',
INIT,
PASSWORD='TryAgain'

"Error: 26 – Error Locating Server/Instance" Specified SQL Server

“An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connection. (provider: SQL Network Interfaces, error: 26 – Error Locating Server/Instance Specified)”

This error might have occured due to the following reasons.

Syndicate content