Click here to Skip to main content
14,491,358 members

how to pass a datetime parameter while executing stored procedure.

Rambo_Raja asked:

Open original thread
my stored procedure is as follows:
ALTER procedure [dbo].[spuserdetails]
@Name varchar(50),
@DOB datetime,
@Age int=null,
@Address1 varchar(70),
@phone int,
@Country varchar(50) = null,
@States Varchar(50) = null,
@City varchar(50) = null

insert into userdetails(Name,DOB,Addr,phn,Country,States,City)
values (@Name,@DOB , @Address1 , @phone , @Country, @States, @City)

when i execute it :
exec  spuserdetails 'smasher','23-12-1989' ,'516-A wills street',761456,'India','kerala','Tri',1

the following error occurs when i execute stored procedure:
Msg 8114, Level 16, State 5, Procedure spuserdetails, Line 0
Error converting data type varchar to datetime.

why? how to pass a datetime parameter in table?
Tags: SQL-Server


When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100