Feed on
Posts
Comments

Archive for the 'MS SQL Server' Category

Have you ever been in a situation when you want to set the next value of the identity column? This is s simple task that can be done with DBCC CHECKIDENT statement. This example deleted all records with ID greater than 135 from the table Products. Than it sets the current identity value to 135. […]

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • dzone
  • Netscape
  • digg
  • YahooMyWeb
  • Technorati

This function uses NEWID() function to create a random password with 8 symbols length:
DECLARE @generated_password varchar(8)        SET @generated_password = LEFT(CONVERT(varchar(255), NEWID()), 8 )
SELECT @generated_password
MS SQL Server, T SQL

Share and Enjoy:
These icons link to social bookmarking sites where readers can share and discover new web pages.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • dzone
  • Netscape
  • digg
  • YahooMyWeb
  • Technorati

Changing the sorting order by passing a parameter to a stored procedure it’s a little bit tricky. The following example will return all the users form table Users (id, first_name, last_name, published_feedbacks_count, positive_feedback_percentage) in the order set by parameters @sort_column and @sort_desc. The parameter @sort_column is used to pass the column to be sorted. The […]

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • dzone
  • Netscape
  • digg
  • YahooMyWeb
  • Technorati

If you have created Data Manipulation Language (DML) triggers in SQL Server, you are aware that you can retrieve information from special tables named inserted and deleted to view the new or previous version of rows. SQL Server 2005 introduces the OUTPUT keyword to provide this same functionality in a simple INSERT, UPDATE, and DELETE […]

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • dzone
  • Netscape
  • digg
  • YahooMyWeb
  • Technorati

Common table expressions (CTEs) are a really cool feature of MS SQL 2005. They let you create queries that work with recursive data and queries that are simpler and therefore more readable. You can use CTE-based recursive queries instead of cursors.
To create a recursive CTE, you must perform the following steps:

Create the anchor member […]

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • dzone
  • Netscape
  • digg
  • YahooMyWeb
  • Technorati

To find the duplicate data in column category_name of table named Categories you can use this SQL Query: SELECT * FROM Categories WHERE Categories.id NOT IN(SELECT MIN(C.id) FROM Categories AS C WHERE Categories.category_name = C.category_name)

 To delete the duplicate data you can use this SQL Query:

DELETE FROM Categories WHERE Categories.id NOT IN(SELECT MIN(C.id) FROM Categories AS C WHERE Categories.category_name […]

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • dzone
  • Netscape
  • digg
  • YahooMyWeb
  • Technorati