CREATE FUNCTION dbo.ValidSerialNumber( @nvcSerialNumber nvarchar(50))
RETURNS BIT
AS
BEGIN
DECLARE
@bValid BIT,
--default to invalid serial number
SET @bValid = 0
IF @nvcSerialNumber LIKE '[0-9][A-Z][0-9][A-Z][0-9][0-9][0-9][0-9]'
BEGIN
SET @bValid = 1
END
IF @nvcSerialNumber LIKE '[0-9][0-9][0-9][A-Z][0-9]5[A-Z]'
BEGIN
SET @bValid = 1
END
RETURN ( @bValid)
END
This code is showing Following error. Why?
Msg 156, Level 15, State 1, Procedure ValidSerialNumber, Line 10
Incorrect syntax near the keyword 'SET'
.