Using User Defined Functions in Table Inserts and Seeding with Stored Procedures

Overview

This article (my first), demonstrates how to automatically set column values with INSERT statements. I show two methods: The first automatically generates a unique code on a Table INSERT using a User-defined Function; while the second uses a Stored Procedure to insert Rows into a table with specified or default index numbers.

Background

Do you ever need to seed index columns like task numbers or steps in a sequence? How about automatically generating a unique code for a customer? My solutions to these problems follow. These may not be the best, or most elegant ways to implement this functionality, but it is a good starter.

The first thing we have to do is open SQL Management Studio (SSMS) and create a sample database named DemoTaskList; then in a new query window, we create our first table:


See full detail: http://www.codeproject.com/KB/database/UDFInserts.aspx

Comments

Popular posts from this blog

Asynchronous Socket Programming in C#

Url Routing MVC TUTORIAL

WCF Chat Sample