June 5, 2009 at 12:37 pm
Ok I created this stored procedure but I keep getting these two errors and I can't seem to figure out why. I'm a bit new to creating these (hence posting in the Newbie section). Basically I'm building an email address and calling the stored procedure in a .NET web form. Any assistance someone could provide or hints would be greatly appreciated. When I execute this query, here are the errors:
Msg 156, Level 15, State 1, Procedure usp_GetMgrEmail, Line 18
Incorrect syntax near the keyword 'AS'.
Msg 156, Level 15, State 1, Procedure usp_GetMgrEmail, Line 26
Incorrect syntax near the keyword 'AS'.
...and here's my procedure...
USE [SchoolLM]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[usp_GetMgrEmail]
@locationId VARCHAR(36) = null,
@identifier VARCHAR(10) = 'School',
@emailAddress OUTPUT
AS
BEGIN
SET NOCOUNT ON;
IF(@identifier = 'School')
--SELECT 'School'
SELECT @emailAddress = (s.Sch_Id + '@' + b.Brn_Domain)
AS email
FROM tblSchool AS s
INNER JOIN tblBrand AS b
ON s.Brn_Id = b.Brn_Id
WHERE s.Sch_Id = 1256
ELSE IF (@identifier = 'District')
--SELECT 'District'
SELECT @emailAddress = (s.Hie_Id + '@abc123.com')
AS email
FROM tblSchool AS s
WHERE s.Sch_Id = 1256
END
June 5, 2009 at 1:11 pm
Try This
USE [SchoolLM]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[usp_GetMgrEmail]
@locationId VARCHAR(36) = null,
@identifier VARCHAR(10) = 'School',
@emailAddress VARCHAR(50) OUTPUT
AS
BEGIN
SET NOCOUNT ON;
IF(@identifier = 'School')
--SELECT 'School'
SELECT @emailAddress = (s.Sch_Id + '@' + b.Brn_Domain)
FROM tblSchool AS s
INNER JOIN tblBrand AS b
ON s.Brn_Id = b.Brn_Id
WHERE s.Sch_Id = 1256
ELSE IF (@identifier = 'District')
--SELECT 'District'
SELECT @emailAddress = (s.Hie_Id + '@abc123.com')
FROM tblSchool AS s
WHERE s.Sch_Id = 1256
END
HWH...
June 8, 2009 at 12:11 pm
Thank you very much. I see where I went wrong. That was quite the simple little mistake too, LOL.
It worked like a charm too. :w00t:
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply