Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Parent/Child List Table Sort Order

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-02-10 : 19:29:12
Sean McNeill writes "I have table called LIST, the only purpose of this table is to keep all of my list value is a single place using a parent/child methodology to distinguish the types of lists I have and values of associated with those lists. With that said, the basic structure of the table looks like this:


CREATE TABLE [dbo].[LIST] (
[LIST_ID] [varchar] (20) NOT NULL PRIMARY KEY,
[LIST_NAME] [varchar] (50) NOT NULL ,
[LIST_ORDER] [int] NULL ,
[PARENT_ID] [varchar] (20) NOT NULL )


As you can see, I have a column called LIST_ORDER, this obviously is used to specify the order of a value in a list. My question is, how can I increment the value of this LIST_ORDER by 1 via a trigger or stored procedure on INSERT. This seed or increment value should start at 1 each time a row is referenced in the PARENT_ID for the first time and increment from there? I hope I was clear in my question. Thanks for your help and this valuable resource....

sm"
   

- Advertisement -