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)
 Help me !

Author  Topic 

ghost0099
Starting Member

2 Posts

Posted - 2009-04-02 : 01:28:22
1. I want to create a procedure :
I create a table "Events", and I want 'EventID' should be auto generated, How must i do ?

2. I create a table 'Payment' and entity 'PaymentMethod'. How to do :
"If the payment method is 'Credit Card', then it need to be unsured that the credit card detials are entered for a new record being inserted into the table. If the payment is not being done using a credit card, it must be ensured that the credit card details are blank."

_______Mr X_______
_______Lonely________
__________________

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-04-02 : 03:18:25
for 1 question try this once
create table sampletable(id int)
DECLARE @refNo VARCHAR(50),
@referencenumber VARCHAR(32)

SELECT @ReferenceNumber = ''

SELECT @ReferenceNumber = MAX(id)
FROM sampletable

PRINT @ReferenceNumber

IF ISNULL(@ReferenceNumber,'') = ''
SELECT @refno = '01'
ELSE
SELECT @refno = RIGHT('00000' + CAST(CAST(RIGHT(@ReferenceNumber, 4) AS INT) + 1 AS VARCHAR(6)), 6)

SELECT @referencenumber = @refno
SELECT @referencenumber
--and then insert the @referencenumber into that column
insert into sampletable select @referencenumber
drop table sampletable
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-04-02 : 03:31:36
Use IDENTITY for EventID column.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -