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 |
sajitha
Starting Member
10 Posts |
Posted - 2012-03-07 : 06:28:39
|
My stored procedure for inserting values into two tables 'newTask' and 'LogsDetail' creating the error as.'Error converting data type varchar to datetime'. I executed this procedure using following values
EXECUTE InsertDetails 'error in creating database ', 'Low', '2012-03-06 14:00:00.000', '2012-03-06 14:00:00.000', 37, 'hams', 'hams@gmail.com', '0435678933', 7
Please help me....Thank you in advance
USE [PMS] GO /****** Object: StoredProcedure [dbo].[InsertDetails] Script Date: 03/07/2012 22:19:09 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- Batch submitted through debugger: SQLQuery1.sql|7|0|C:\Users\sarj\AppData\Local\Temp\~vsD619.sql ALTER PROCEDURE [dbo].[InsertDetails] ( @UserName nvarchar(50) = NOTNULL, @Email nvarchar(50)=NOTNULL, @DateCreated datetime = NOTNULL, @Description nvarchar(max) = NOTNULL, @Priority nvarchar(50) = NOTNULL, @DueDate datetime = NULL, @RequesterPhone nvarchar(50) = NULL, @newCategory nvarchar(50)=NOTNULL, @RequesterID INT ) AS
DECLARE @CatID INT SET @CatID = (SELECT TOP 1 Category.CategoryID FROM Category WHERE Category.CategoryName=@newCategory) INSERT INTO newTask(Description, Priority, CreatedDate, DueDate, RequesterUserID, RequesterName, RequesterEmail, RequesterPhone, Category) VALUES (@Description, @Priority, @DateCreated, @DueDate, @RequesterID, @UserName, @Email, @RequesterPhone, @CatID) DECLARE @TaskID INT SET @TaskID = Scope_Identity()
INSERT INTO LogsDetail(TaskID, LogDescription, DateCreated, UserID) VALUES (@TaskID, @Description, @DateCreated, @RequesterID)
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2012-03-07 : 06:56:33
|
Have a look at the order of parameters. In your example 'hams' is going into @DueDate.
No, you're never too old to Yak'n'Roll if you're too young to die. edit: typo |
 |
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-03-07 : 06:57:37
|
Looks like you are providing the parameter values in the execute statement in the wrong order. The sixth parameter you are providing is 'hams', but the stored procedure is expecting @DueDate which is of type datetime. That may be the source of the error.
|
 |
|
sajitha
Starting Member
10 Posts |
Posted - 2012-03-07 : 07:12:51
|
Thank you very much guys....its worked |
 |
|
|
|
|
|
|