I ‘ve used the Query Builder tool of Visual Studio 2008 to build a stored procedure. This is the preview script:
IF EXISTS (SELECT *
FROM sysobjects
WHERE name = 'SelectQuery' AND user_name(uid) = 'dbo')
DROP PROCEDURE dbo.SelectQuery
GO
CREATE PROCEDURE dbo.SelectQuery
(
@StudentID int
)
AS
SET NOCOUNT ON;
SELECT StudentID, StudentName, StudentPhone, StudentAddress,
StudentBirthDay, StudentDescription, StudentStatus
FROM tbl_Student
WHERE (StudentID LIKE '%' + @StudentID + '%')
GO
But when I tried to execute it, I got an error:
Error Message: Conversion fail when converting the value '%' to datatype int.
Please help me!
You want to find rows where
@StudentIDis a substring ofStudentID? If soShould work.