How to insert current date into table using stored procedure?

asp.net, c#, sql-server-2008

Solution

If you always want the current date as the value for the CreationDate column you could use a default on the table and modify your proc to just take @mediumnamn as parameter. Or you could modify it to this:

alter procedure insertmediumproc @MediumName varchar(50)
as begin
insert into medium (MediumName, CreationDate) values (@MediumName,getdate())
end

That way you don't have to send the date as a parameter.

Problem

I am having a table with name medium and there is a column name medium name and creation date i have created stored procedure to insert specific above two values .below is my stored procedure ``` alter procedure insertmediumproc @MediumName varchar(50) ,@CreationDate datetime as begin insert into medium (MediumName, CreationDate) values(@MediumName,getdate()) end ``` when i tried to insert values in table with command below: ``` exec insertmediumproc Nepali,getdate() ``` it is showing error below: Msg 102, Level 15, State 1, Line 1 Incorrect syntax near ')'.

Original source

Related problems