T-SQL
RowNumber Alternative in Linq
Submitted by ranjit on Mon, 08/02/2010 - 22:39I want to know, Do we have any alternative to Row_Number function in Linq. I want to use Ranking and Partition in Linq.
SELECT ROW_NUMBER() OVER(Partition BY Author_Name
Please let me know how to achieve the same functionality in Linq.
Row Number function in SQL Server
Submitted by vaibhav on Fri, 06/18/2010 - 16:31I 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?
Submitted by vaibhav on Tue, 06/15/2010 - 18:05I 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.
What is the difference between Stored Procedures and User Defined Functions?
Submitted by vaibhav on Fri, 02/12/2010 - 20:20What is the difference between Stored Procedures and User Defined Functions in sqlserver.
Set two variables using a Select query in a stored procedure.
Submitted by shantanu on Wed, 12/09/2009 - 21:59SET @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: Backup and Restore Database using T-SQL
Submitted by vaibhav on Wed, 11/11/2009 - 12:18Its 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'