beginner to store procedures

Results 1 to 3 of 3

Thread: beginner to store procedures

  1. #1
    yls Guest

    Default beginner to store procedures

    hi, i am moving towards stored procedures.. I have coded my own stored proceures already. one of them is as belows<BR><BR>create procedure showrecord<BR> @id nvarchar(40)<BR>as<BR> select * from member where id @id<BR><BR>i have a few questions. firstly, how to write a trigger such that the code will check whether the id exists for this scenario and for others will be like, inserting an existing record, deleting a non-existent record or to sum it up, coding business logic into procedures. thanks

  2. #2
    Steve W Guest

    Default RE: beginner to store procedures

    Don&#039t ask for much, do you? ;-)<BR><BR>A great T-SQL keyword for the kind of decision making you are talking about is EXISTS. For example:<BR><BR> IF EXISTS (SELECT memberid <BR> FROM member <BR> WHERE memberid = @memberid)<BR><BR> BEGIN<BR> &#060;whatever&#062;<BR> END<BR><BR>will enable you to perform an action depending on whether the specified record already exists. This should give you the basis for everything else.<BR><BR>Good luck!<BR>

  3. #3
    yls Guest

    Default RE: beginner to store procedures

    IF EXISTS (SELECT memberid <BR>FROM member <BR>WHERE memberid = @memberid)<BR><BR>BEGIN<BR>&#060;whatever&#062;<BR >END<BR><BR>from the above, the begin will be activated when the memberid already exists?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts