Insert value in Procedure

Posted by Senthilmcatyr under Sql Server on 8/23/2011 | Points: 10 | Views : 954 | Status : [Member] | Replies : 5
Hi,
I create find date missing procedures in sql. I have successfully create it. how to automatically insert missing date when i execute procedure? pls send automatically insert query..........


Regards,
SenthilKumar.s




Responses

Posted by: Vuyiswamb on: 8/23/2011 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
i really dont understand what you want to achieve , please explain clearly

Thank you for posting at Dotnetfunda
[Administrator]

Senthilmcatyr, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: A4u_6178 on: 8/23/2011 [Member] Starter | Points: 25

Up
0
Down
Hi Senthilmcatyr,

would u pls post ur table and procedure code..

Thanks & Regards,

Senthilmcatyr, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: A4u_6178 on: 8/23/2011 [Member] Starter | Points: 25

Up
0
Down
@Senthilmcatyr,

I have created a database table as follows
create table schedule (Id int, EmployeeName varchar(90), DateOfJoining date)


Now I have created a stored procedure with following parameters and date field automatically inserted by
GETDATE()

create procedure Insert_Date_Automatically(

@ID int,
@EmpName varchar(90))
as
begin
--Set no count ON To no longer get rows affected messages..
SET NOCOUNT ON
insert into schedule values(@ID,@EmpName,getdate())
end


Now the execution of procedure is
Exec Insert_Date_Automatically 2,'charlie'

as u can see only 2 parameters are passed in stored procedure but datefield is not been passed in stored procedure this field is been inserted by GETDATE() function as i said before.

Thanks & Regards,

Senthilmcatyr, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sagarsj on: 8/23/2011 [Member] Starter | Points: 25

Up
0
Down
getdate() function will Returns the current database system timestamp as a datetime value without the database time zone offset. This value is derived from the operating system of the computer on which the instance of SQL Server is running.

wat exactly u want in tht field?
and wat do u mean by Missing Date???

Please clarify.

Sagar

Senthilmcatyr, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: PandianS on: 8/23/2011 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi

Let me confirm something.

Are you asking about Optional Parameters in Stored procedure ?

If you not passing the Date Parameter then, It should take the current date automatically ?
- If so, You can use Optional Parameter for the Date parameter and Validate inside the stored procedure before Insert into the table

(or)

If you not Inserting any Date in table then, It should take the system date automatically ?
- If so, Define DEFAULT rule in column.

Cheers
www.SQLServerbuddy.blogspot.com
iLink Multitech Solutions

Senthilmcatyr, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response