Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

Incremental Line Number on a group

$
0
0

Hi all,

I'm trying to increment a line QTY based on a group for a basic Purchase Order System but cant get the incremental number to reset on each group change.

I currently have the following to create my table but the line number just increases by one each time,

USE [PurchaseOrders]
GO

/****** Object: Table [dbo].[Pord_Line] Script Date: 01/03/2014 16:48:33 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[Pord_Line](
[Ref] [int] NOT NULL,
[Line] [int] IDENTITY(1,1)NOT NULL,
[Part] [varchar](50) NOT NULL,
[Description] [varchar](50) NULL,
[Supplier_Part] [varchar](50) NULL,
[Qty] [numeric](18, 0) NOT NULL,
[Unit_Price] [numeric](18, 2) NOT NULL,
CONSTRAINT [PK_Pord_Line] PRIMARY KEY CLUSTERED
(
[Ref] ASC,
[Line] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

Thanks again


Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>