Posts

Showing posts with the label MS SQL

Comparing cursor vs. WHILE loop performance

Cursors Cursors are a looping construct built inside the database engine and come with a wide variety of features. Cursors allow you to fetch a set of data, loop through each record, and modify the values as necessary; then, you can easily assign these values to variables and perform processing on these values. Depending on the type of cursor you request, you can even fetch records that you’ve previously fetched. Because a cursor is an actual object inside the database engine, there is a little overhead involved in creating the cursor and destroying it. Also, a majority of cursor operations occur in tempdb, so a heavily used tempdb will be even more overloaded with the use of cursors. The types of cursors used are very important in terms of performance. Below is a list of the available cursor types as listed on     FORWARD_ONLY Specifies that the cursor can only be scrolled from the first to the last row. FETCH NEXT is the only supported fetch option. If FORWARD_O

Generate MS SQL DataBase Script with Data in Sql Server 2008 and Visual Studio 2010

Image
Generate MS SQL  Data Base Script with Data in Sql Server 2008 and Visual Studio 2010 1     1. Open Visual Studio 2010 2         2. Go to Tools->Connect to Data Base 3         3. Open Server Explorer right click on Data Base and select Publish to provider Click Next and Chose the type of data publish Click next and finish
How to ignore duplicate value Error while inserting the record in unique index? When unique index is created without any option the default option is IGNORE_DUP_KEY = OFF , which means when duplicate values are inserted it throws an error regarding duplicate value. such as   Msg 2601, Level 14, State 1, Line 9 Cannot insert duplicate key row in object 'dbo.QODT4' with unique index 'Q4_INDEX'. If option is set with IGNORE_DUP_KEY = ON then the duplicate values are inserted it does not thrown an error but just displays warning.   such as (1 row(s) affected) Duplicate key was ignored.