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.
    
        | 
                
                    | 
                            
                                | Author | Topic |  
                                    | sepalaStarting Member
 
 
                                        1 Post | 
                                            
                                            |  Posted - 2010-07-21 : 10:44:58 
 |  
                                            | I have to do a project in SQL. I have a TABLE called payments and I have to create a auto generation ID for the "PaymentID" column. here is the table structure.create table Payments(PaymentID int identity (1,1) constraint pkpaymentid primary key,ProjectID char (10),PaymentAmount money constraint chkpaymentamount check (PaymentAmount>0),PaymentDate datetime,CreditCardNumber char (15),CardHoldrsName char (20),CreditCardExpiryDate datetime,PaymentMethodID char (10))In this case I have used "IDENTITY" for generate the paymentID. But my lecturer said I have to generate PaymentIDs like 'C001' AND 'C002' rather than just generating a number. He said me I can do it using a stored procedure (in that case all the insertions to Payments table should happen through the stored procedure). Now I am strugling with this for 2 weeks but still I couldn't find a solution. Can anyone show me how to write that coding? I have to MS SQL 2000. Please help..yoisman |  |  
                                    | dinakarMaster Smack Fu Yak Hacker
 
 
                                    2507 Posts | 
                                        
                                          |  Posted - 2010-07-21 : 15:08:47 
 |  
                                          | You can create another column for your string counterpart and leave the PaymentID as IDentity column.. and make these two columns together primary key.. and concatenate them when showing in the application..Dinakar Nethi************************Life is short. Enjoy it.************************http://weblogs.sqlteam.com/dinakar/ |  
                                          |  |  |  
                                |  |  |  |