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 |
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 oncecreate table sampletable(id int)DECLARE @refNo VARCHAR(50),@referencenumber VARCHAR(32)SELECT @ReferenceNumber = ''SELECT @ReferenceNumber = MAX(id)FROM sampletablePRINT @ReferenceNumberIF ISNULL(@ReferenceNumber,'') = ''SELECT @refno = '01'ELSESELECT @refno = RIGHT('00000' + CAST(CAST(RIGHT(@ReferenceNumber, 4) AS INT) + 1 AS VARCHAR(6)), 6)SELECT @referencenumber = @refnoSELECT @referencenumber--and then insert the @referencenumber into that columninsert into sampletable select @referencenumberdrop table sampletable |
|
|
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" |
|
|
|
|
|