Stored procedures from Access in MS SQL Server

  • The main problem is how to pass only one variable or 2 variables or more into SP. 
    And what if my variables will be null ?

    Jacek

  • Maybe something like this? 

    CREATE PROCEDURE spDoSearch 
    @FirstName varchar(25) = null, 
    @LastName varchar(25) = null, 
    @Title varchar(25) = null
    AS BEGIN  
    SELECT ID, FirstName, LastName, Title  FROM tblUsers  
    WHERE   (@FirstName IS NULL OR FirstName = @FirstName)
    AND   (@LastNameName IS NULL OR LastName = @LastName)
    AND   (@Title IS NULL OR Title = @Title)END

    Best Wishes,
    thank you in advanve for help and support,
    Jacek 

  • Anyone please?

  • Be careful with that approach.  Please see here.

    John

Viewing 4 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply