Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stored Proc Question

Status
Not open for further replies.

nerdalert1

Programmer
Nov 4, 2004
92
US
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?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top