nerdalert1
Programmer
Hello all. In a proc what is the best way to handle this. I have a parameter getting passed in called @PageName
I need to check if this name exists in a table I have. If it does not then I want to INSERT a record. I know I can handle it this way below but I think this must be a better way.
tblPages has an Identity Column called PageID with the field PageName
So currently I am doing it this way.
DECLARE @PAGEID AS INT
SELECT @PAGE = PAGEID FROM tblPages WHERE PageName = @PageName
IF @PAGE IS NULL
BEGIN
--INSERT STATEMENT HERE
END
Is there a better way?
I need to check if this name exists in a table I have. If it does not then I want to INSERT a record. I know I can handle it this way below but I think this must be a better way.
tblPages has an Identity Column called PageID with the field PageName
So currently I am doing it this way.
DECLARE @PAGEID AS INT
SELECT @PAGE = PAGEID FROM tblPages WHERE PageName = @PageName
IF @PAGE IS NULL
BEGIN
--INSERT STATEMENT HERE
END
Is there a better way?