Hi , I'm newbie for SQL.I'm stuck with a problemI've following tableAddress ( AddressID TINYINT NOT NULL, CustomerID INT NOT NULL, Address VARCHAR(200) NOT NULL)
AddressID and CustomerID are composite Primary Key.CustomerID is Foreign Key to Customer Table.What i want is automatic increment AddressID with same CustomerIDSuppose that , we'll add 3 addreses for customer whose id is 1 and 4 addresses for the customer whose id is 2.So my table shall look likeAddressID CustomerID Address1 1 '......'2 1 'blabla'3 1 '...'1 2 '..'2 2 '....'3 2 '.....'4 2 '....'
AddressId shall increment and automatically become 1 when it's entered different CustomerIDHow can i do it ? How shall i write my stored procedure?Btw, I use Microsoft SQL Server 2008.Thanks in advance