Reputation: 2750
I am trying to write a stored procedure. But getting this strange error.. Would be nice if anybody can help me...
this is my stored proc.
ALTER PROCEDURE [dbo].[Usp_search] (@keyword NVARCHAR(500))
AS
BEGIN
DECLARE @tab TABLE (
id UNIQUEIDENTIFIER,
Title NVARCHAR(250),
Description NVARCHAR(500),
FilePath NVARCHAR(500),
UploadDate DATETIME,
FileName NVARCHAR(250),
CourseName NVARCHAR(150),
FullName NVARCHAR(250),
School NVARCHAR(250))
INSERT INTO @tab
SELECT un.Id,
un.Title,
un.Description,
un.FileName,
un.FilePath,
uc.CourseName,
up.Fullname,
up.School,
un.UploadDate
FROM UserNotes un
INNER JOIN UserCourse uc
ON un.CourseId = uc.Id
INNER JOIN UserProfile up
ON up.Id = un.UserId
WHERE FREETEXT(( un.Title, un.Description, un.Tag ), @keyword)
SELECT *
FROM @tab
RETURN
END
--exec usp_search 'mvc'
this is the error: Conversion failed when converting date and/or time from character string.
Upvotes: 0
Views: 1502
Reputation: 6574
You are not specifying the columns in your select statement in the same order that they are declared in your table.
So either add a columns clause to your insert - e.g.
INSERT INTO @tab (ID, Title, Description ...)
Or change the order of the columns that you are selecting. It would seem to me that you want
SELECT un.Id,
un.Title,
un.Description,
un.FilePath,
un.UploadDate,
un.FileName,
uc.CourseName,
up.Fullname,
up.School
...
Upvotes: 2