| Author |
Topic  |
|
|
kwacz23
Starting Member
14 Posts |
Posted - 05/16/2012 : 13:37:56
|
Hello I need help with that procedure. I would like to add autonumber to id_rezerwacji. this is the last part of that procedure
Exec add_reservation 3,4
Decription parametrs 3-it is a number for one activity 4- it is client number id_reservation here I want automatic number data-it is getdate-automatic
create procedure @add_reservation @id_gym_activities int,@p_id int,@id_reservation int output,@data_reservation datetime as begin
insert rezerwacje (Id_konktetnych_zajec,P_id,id_rezerwacji,[Data rezerwacji],id_status) values (@id_konkretnych_zajec,@p_id,@id_rezerwacji,getdate(),'4') select @@IDENTITY end go |
|
|
jimf
Flowing Fount of Yak Knowledge
USA
2865 Posts |
Posted - 05/16/2012 : 13:52:56
|
If you make a column as id_reservation int identity(1,1) in you table, that will automatically increase by 1 everytime you insert in to it. Also, use select scope_identity() instead of @@identity.
Jim
Everyday I learn something that somebody else already knew |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
India
47023 Posts |
Posted - 05/16/2012 : 20:15:18
|
quote: Originally posted by kwacz23
Hello I need help with that procedure. I would like to add autonumber to id_rezerwacji. this is the last part of that procedure
Exec add_reservation 3,4
Decription parametrs 3-it is a number for one activity 4- it is client number id_reservation here I want automatic number data-it is getdate-automatic
create procedure @add_reservation @id_gym_activities int,@p_id int,@id_reservation int output,@data_reservation datetime as begin
insert rezerwacje (Id_konktetnych_zajec,P_id,id_rezerwacji,[Data rezerwacji],id_status) values (@id_konkretnych_zajec,@p_id,@id_rezerwacji,getdate(),'4') select @@IDENTITY end go
are you trying to retrive the generated id value by last statement?
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
|
 |
|
| |
Topic  |
|
|
|