Procedure to check to letters in a collum

Hi,I have a table called "check_in_time"
I have columns
ID integer
customer_name varchar2(10 BTYES)
check_in_time (5 BTYES)
check_out_time varchar2(5 BTYES)
Because this schema is manage by a different person I CANNOT change the datatype for it.
The issue now is that the users for this system can some putting in letters in the "check_in_time" instead of 12:00 for an example
and for this reason another application looking at "check_in_time" will pop up an error and this is start different issues because
you are not sure what time the guest check in.
to stop this I want to rewrite a pl/sql procedure which runs every 12 hours and then send me and email to me. If the check_in_time column
as a letter or anything other than time because 00:00 to 23:59.
is this possible? if yes please can you show me and example.
Thanks

Can you add a constraint to the table?
In that case, you could check for the correct format. Of course, you would have to clean up all faulty data first.
Example:
sql> create table test_time( check_in_time varchar2(5));
Table created.
sql> alter table test_time add ( constraint ck_check_in_time1
  2    check ( regexp_like(check_in_time, '^([0-1]?[0-9]|2[0-3]):[0-5][0-9]$') ));
Table altered.
sql> insert into test_time values ('12:34');
1 row created.
sql> insert into test_time values ('23:59');
1 row created.
sql> insert into test_time values ('2:34');
1 row created.
sql> insert into test_time values ('24:21');
insert into test_time values ('24:21')
ERROR at line 1:
ORA-02290: check constraint (P1ECOM.CK_CHECK_IN_TIME1) violated
sql> insert into test_time values ('ab:14');
insert into test_time values ('ab:14')
ERROR at line 1:
ORA-02290: check constraint (P1ECOM.CK_CHECK_IN_TIME1) violated
sql> select * from test_time;
CHECK
12:34
23:59
2:34
sql> drop table test_time;
Table dropped.
But obviously, it is always better to store a time as a (date)time, not as a string.

Similar Messages

  • Checking for letters and numbers

    Guys, i need to check a String to see if contains either letters or numbers and nothing else. I know that there's certain function is could use like:
    1. isNum() - to check for numbers
    2. isChar()-to check for letters
    but the things is that i get error when i tried to use either 1 of these methods.
    So is there any other methods i could use to do this validation??
    Thx Guys

    Ooo.. i saw that 2 method too but it says that it onli accept character but not string and wat i wan to check is a String.

  • Procedure to check the existence of Indexes

    I have a procedure whcih drops all the indexes, when the same procedure is executed again, it gives error "object does not exists" (obviously)
    I want to avoid this error, how can I check the existence of index inside the procedure, so that the procedure will check if the index exists before deleting the index?
    Is there a ready-made procedure available for such scenario?
    Thanks in advance

    The other approach is to catch the exception in your script, i.e.
    BEGIN
      EXECUTE IMMEDIATE 'DROP INDEX <<index name>>';
    EXCEPTION
      WHEN OTHERS THEN
        -- Drop failed.  Do something to record the failure.
        NULL;
    END;Now, most of the time, you'll want to catch a few specific exceptions and you'll want to do something when you catch them (i.e. generate a log entry).
    Justin

  • Write a procedure to check the count is less than 1300 for every 3 hours

    Good Morning all,
    I want to write a procedure to check the count is less than 1300 for every 3 hours
    Query:*
    Select count(*) from sample where trx_date=sysdate;
    I want to run this query every 3 hours daily
    If the count is less than 1300 every 3 hours, we should sent a reminder mail like 'Data not copy'.
    Please help me how to write a procedure.

    hi there
    first
    --define the SMTP_OUT_SERVER parameter in your init.ora initialization file
    --ALTER SYSTEM SET smtp_out_server='my.domain.com' SCOPE=SPFILE;
    after that create a procedure
    CREATE OR REPLACE procedure SCOTT.hrsmail
    is
    v_count number;
    begin
    Select count(*)  into v_count from emp;
    if v_count < 1300
    then
      UTL_MAIL.send(sender    => '[email protected]',
                      recipients => '[email protected]',
                      cc         => '[email protected]',
                      bcc        => '[email protected]',
                      subject    => 'Testing the UTL_MAIL Package',
                      message    => 'If you get this, UTL_MAIL package
    else
    null;   --what you want to do here
    end if ;
    end;
    /we should create a job which run after every 3 hrs and send a reminder mail like 'Data not copy'.
    BEGIN
      SYS.DBMS_JOB.REMOVE(373);
    COMMIT;
    END;
    DECLARE
      X NUMBER;
    BEGIN
      SYS.DBMS_JOB.SUBMIT
      ( job       => X
       ,what      => 'begin hrsmail; end;'
       ,next_date => to_date('14/02/2011 18:39:29','dd/mm/yyyy hh24:mi:ss')
       ,interval  => 'SYSDATE+3/24 '
       ,no_parse  => FALSE
      SYS.DBMS_OUTPUT.PUT_LINE('Job Number is: ' || to_char(x));
    COMMIT;
    END;
    /hope this will help you
    Regards
    Hitesh
    Edited by: Hitesh Nirkhey on Feb 14, 2011 3:34 PM

  • Approval procedure to check and pop up alert when Inventory transfer

    HI Experts,
    I want to do an approval procedure to check and pop up alert when Inventory transfer To warehouse 01 by Query.how to query for the following statement in Approval Procedure?
    Regards,

    Hi,
    This query is also used in the approval procedure of inventory transfer created:
    if (SELECT $[$5.1.0]) = '01'
    select 'true'
    it will gives alert after document approved or requesting approval.
    Rgds,

  • Stored Procedure for checking Invoice Vendor ref No

    Hi All
    I need a sp for checking a vendor ref no  on an invoice if it already exist in the system or the user forgot to include one when trying to add the document.
    I get this error on the one that I created
    16/03/2010  12:21:54: [Microsoft][SQL Native Client][SQL Server]Conversion failed when converting the nvarchar value '24     0' to data type int. (CINF)
    Here is my SP :-
    DECLARE @Invoice AS VARCHAR(15)
    DECLARE @Card AS VarChar (20)
    SELECT @invoice = NumatCard, @card = CardCode FROM dbo.OPCH
    WHERE DocEntry = @list_of_cols_val_tab_del
    if @object_type = '18' and @transaction_type in (N'A', N'U') -- AP Invoice is null
    begin
        If exists (SELECT T0.cardcode, T0.NumAtCard  FROM OPCH T0 where T0.NumatCard is null and  T0.cardcode=@list_of_cols_val_tab_del)
         begin
              SET @error = 10
              SET @error_message = N'Supplier invoice number not entered.'
         END
    END
    SELECT @INVOICE = NumatCard FROM dbo.OPCH
    WHERE DocEntry = @list_of_cols_val_tab_del
    if @object_type = '18' and @transaction_type in (N'A', N'U') -- AP Invoice to check if the invoice no exist
    begin
        If exists (SELECT T0.cardcode, T0.NumatCard  FROM OPCH T0 where T0.NumatCard = @invoice  and  T0.cardcode=@list_of_cols_val_tab_del)
         begin
              SET @error = 10
              SET @error_message = N'This invoice number already exist for this supplier.'
         END
    END
    Regards
    Bongani Dlamini

    This code should be inserted into the original (or already expanded) SBO_SP_TransactionNotification stored procedure after the line
    --     ADD     YOUR     CODE     HERE )
    Try this full (and a little modified) procedure:
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER proc [dbo].[SBO_SP_TransactionNotification]
    @object_type nvarchar(20),                     -- SBO Object Type
    @transaction_type nchar(1),               -- [A]dd, <u>pdate, [D]elete, [C]ancel, C[L]ose
    @num_of_cols_in_key int,
    @list_of_key_cols_tab_del nvarchar(255),
    @list_of_cols_val_tab_del nvarchar(255)
    AS
    begin
    -- Return values
    declare @error  int                    -- Result (0 for no error)
    declare @error_message nvarchar (200)           -- Error string to be displayed
    select @error = 0
    select @error_message = N'Ok'
    --     ADD     YOUR     CODE     HERE
    if @object_type = '18' and @transaction_type in (N'A', N'U') -- AP invoice
    BEGIN          ----
    DECLARE @Invoice AS VARCHAR(15)
    DECLARE @Card AS VarChar (20)
    SELECT @invoice = NumatCard, @card = CardCode FROM dbo.OPCH
         WHERE DocEntry = @list_of_cols_val_tab_del
    -- AP Invoice is null
    If exists (SELECT T0.cardcode, T0.NumAtCard FROM OPCH T0 where T0.NumatCard is null
               and T0.DocEntry=@list_of_cols_val_tab_del)
    begin
    SET @error = 10
    SET @error_message = N'Supplier invoice number not entered.'
    end
    -- AP Invoice to check if the invoice no exist
    If exists (SELECT T0.cardcode, T0.NumatCard FROM OPCH T0 where T0.NumatCard = @invoice
               and T0.CardCode=@card and T0.DocEntry!=@list_of_cols_val_tab_del)
    begin
    SET @error = 10
    SET @error_message = N'This invoice number already exist for this supplier.'
    end
    END          ----
    -- Select the return values
    select @error, @error_message
    end

  • Stored procedure for checking Invoice value if more than R 15 000

    Hi All
    I have a problem with my stored procedure below, i want to check the doctotal if it above R 15 000 , if it is then it checks if the supplier has a tax clearance cert.
    IF @transaction_type = 'A' AND @object_type = '22'
    BEGIN
    If exists (SELECT T0.cardcode, t0.docentry  FROM OPOR T0 where T0.DOCTOTAL >'15,000.00' and T0.U_TAXCLEAR IS NULL AND T0.docentry=@list_of_cols_val_tab_del)
         begin
              SET @error = 10
              SET @error_message = N'Amount is above R 15 000 please select Supplier with Valid Tax Certificate'
    END
    END
    I tried this executing the sp and there was this error
    Msg 208, Level 16, State 6, Procedure SBO_SP_TransactionNotification, Line 41
    Invalid object name 'dbo.SBO_SP_TransactionNotification'.
    In this case line 41 is 2nd END.
    Thanks
    Bongani Dlamini

    Hi all
    Thanks for the replies , forgot to mention a few requirements.
    In addition to the to checking the value above  R 15 000 I want to check if a tax certificate field is populated , if it is then checks if the expiry date is not null.
    please check the query I tried below.
    IF @transaction_type = 'A' AND @object_type = '22'
    BEGIN
        IF EXISTS (SELECT T0.CardCode FROM dbo.OPOR T0
        WHERE T0.DOCTOTAL > 15000 AND T0.U_TAXCLEAR IS NULL AND T0.DocEntry=@list_of_cols_val_tab_del)
        BEGIN
    SET @error = 10
    SET @error_message = 'Amount is above R 15 000, a valid Tax Certificate is required'
    END
    END
    IF @transaction_type = 'A' AND @object_type = '22'
    BEGIN
        IF EXISTS (SELECT T0.CardCode FROM dbo.OPOR T0 WHERE T0.U_EXPIRYDATE IS NULL AND T0.DocEntry=@list_of_cols_val_tab_del)
        BEGIN
    SET @error = 10
    SET @error_message = 'Tax Certificate expiry date is required'
    END
    END
    Thanks
    Bongani Dlamini

  • Procedure not checking each sql statement.

    Hi All,
    I have created 2 tables names are A1 and B1. A1 table has some fields. Fields are no,sal,comm.,load_date. In A1 table NO (column) is the primary key.
    Second table is B1. this table has id,phone_no and load_date. In this table constraint
    ID column is the Not null.
    After that I have created 2 procedures one for A1 and one for B1. with in those procedures I used SQL insert statements.
    In procedures I used some valid sql statements and some invalid statements ( invalid statements means that I have specified constraint that’s why I specified duplicated and null values). While executing the procedures procedure shows error because of invalid statement and in that procedures I did not specify any Exceptions.
    If I specify Exceptions in procedures executing successfully some records are not loading procedure is comeing out. How do we mention server needs to be check and every insert sql startement.
    EX:
    If I give 6 records from 1 to 3 valid statements. I mentioned 4 th record copy of previos record( duplicated). 5 th record and 6 th valid records.
    Procedure executing successfully. Procedure loaded 1 to 4 records after that not loaded 5,6 and 7 records. How do we specify for record inserts 7. actually 7 th record is valid statement we should be insert this record. Please tell me how do we handle sql statements each and every one successfully or not.
    create or replace procedure a_proc as
    --declare
    begin
    insert into a1 values (100,2000,300,sysdate);
    insert into a1 values(200,1000,400,sysdate);
    insert into a1 values(300,3000,500,sysdate);
    insert into a1 values(400,6000,600,sysdate);
    insert into a1 values(400,900,700,sysdate);
    insert into a1 values(400,10000,1200,sysdate);
    insert into a1 values(900,11000,1300,sysdate);
    commit;
    EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('ERROR - '||sqlerrm);
    end a_proc;
    In B1 table colums are ID,PHONE_NO and Load_date. ID is not null column.
    For B1 population I have created one procedure
    create or replace procedure b_proc as
    --declare
    begin
    insert into b1 values(1,123456,sysdate); -- 1 record
    insert into b1 (phone_no,load_date) values (7896538,sysdate); --2 record
    insert into b1 (phone_no) values(6763723458); ----3 record
    insert into b1 (phone_no) values(453465778); --4 record
    insert into b1 values(400,72894894,sysdate); --5 record
    insert into b1 values(500,72894894,sysdate); --6 record
    commit;
    EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('ERROR - '||sqlerrm);
    end b_proc;
    if I execute above procedure procedure executing successfully but procedure inserting only first record not inserting 5th and 6th record. How do we exception for 5th and 6th records also.
    Thanks and Regards,
    Venkat

    {color:#808080}{color:#333300}Hi,
    Please find answer to your question below:{color}
    Venkat: Procedure executing successfully. Procedure loaded 1 to 4 records after that not loaded 5,6 and 7 records. How do we specify for record inserts 7. actually 7 th record is valid statement we should be insert this record. Please tell me how do we handle sql statements each and every one successfully or not.
    {color}
    {color:#0000ff}Guna: The procedure hits an exception after 4th record, and does not process anymore as it exits out of the procedure, I believe the data is not committed as well. You need handle exceptions if the processing has to continue. Same is the belwo case as well
    {color}{color:#333300}Regards,
    Guna{color}

  • RTP Procedure _Plz Check

    Hi Gurus,
    I am trying the RTP scenario as, plz check
    1. Create Material Master for RTP( Material Type LEIH) i.e. cylinder.
    2. Create PO  for N2 gas( diff material)
    3. Enter MIGO  for N2 gas(101 mov type)
    4. Enter MIGO for RTP materila(501 M mov type)
    5. Enter MIRO.
    Results:
    1. RTP Stock increases(MMBE)
    2. Not shown in material master.
    3. Not valuated.
    But the above procedure i need to enter every time. 
    Plz suggest is the procedure right or wrong?
    Also i am not able to do the procedure as written in literature as:
    A quantity of returnable transport packaging can be entered at goods receipt for a purchase order as follows:
    1. From the Inventory Management menu, choose Goods movement
    2. ® Goods receipt ® For purchase order ® PO number known or PO number unknown. On the initial screen enter the movement type (usually 101) and the order number (or the selection criteria for the purchase order).
    3. Select the required items and copy them.
    4. From the overview screen, choose Edit
    ® W/o purchase order ® Enter...
    A window appears in which you can enter the movement type and the special stock indicator (e.g. 501 M) for the quantity of returnable transport packaging.
    5. Enter the returnable transport packaging items.
    6. Post the goods movement.
    Also i am not able to understand the line,
    This special stock data is defined for every vendor at the storage location level.
    Plz suggest is there any setting missing.
    Plz help me out, it's urgent
    Thanks

    hi,
    Important Points to be remembered.
    1.We can use any material for RTP or we can use LEIH material type for a material of RTP type.
    2.During GR we do it with respect to PO so the material ordered within the PO displays as default. In order to get the RTP material we add a separate material with 501 M mvt type. The order material will have 101 mvt type.
    3.Initial Entry for RTP is also possible with MB1C 561 M.
    4.Transfer posting of RTP material from one storage location to another can also me done with the mvt type 311 M.
    5.You post a return with reversal movement types 502 M and 562 M.
    Thanks & Regards,
    Kiran

  • Checke for letters in string (9i)

    Hi All,
    I have a string, something like "01A" and I would like to:
    1 - Check if it end with letters, it can be any letter.
    2 - split the numbers and the letters to get for example "01" and "A" in seperate variables.
    I know that it would be very easy to do with regular expressions but I am using Oracle 9i so I can't.
    thanks for helping.
    Alex

    substr(yourstiring,-1) will give you the last character
    you could use BETWEEN to figure out if it is a character (e.g. between 'a' and 'z')
    For your second question, look up TRANSLATE in the help.
    Basically you can create a version of your string that has either the character or numeric part "masked" by a particular character, then use INSTRING and SUBSTRING to select out the unmasked part.

  • Need a procedure to check reserve words are in uppercase or not?

    Hi All,
    i am using oracle 11g,
    my question is  i wanted to create procudure and i  am passing a sql query as input parameter  and there i am using lots of oracle reserve keywords. but i need to check if  those reserve keywords are  not in uppercase
    it should show error message and error line.  suppose my query is like below and it should show which line error is?
    SELECT FINDING_LEVEL_ID 
    ,PROTOCOL_SETUP_ID
    ,FLV_LAST_MODIFIED_BY
    ,FLV_LAST_MODIFIED_ON
      FROM empb
    Where EXISTS (SELECT 1
              FROM dept  a
             Where a.PROTOCOL_SETUP_ID = b.PROTOCOL_SETUP_ID
               AND PROTOCOL_LAST_MODIFIED_ON >
                   to_date(ms_sra_get_max_date_fnc('N'
                                                  ,'SGMGBI')
                          ,'DD-MON-YYYY HH24:MI:SS'));
    suppose error is there in where key word  so it should show errorline and error message, but error message is common for every line.
    please help me
    Thanks
    Damby

    913349 wrote:
    Hello Ramin,
    but i need as dyanamic,i cant write always select exist from dual or select 'select' where  from dual .
    anyway i need to pass as parameter.
    Thanks
    Damby
    I don't read other posts , I gave you only example... If you have table  with this words you should replace RS to your table name. And write pl/sql code for procedure.
    with rs(a) as
    select 'WHERE' FROM DUAL UNION ALL
    select 'FROM' FROM DUAL UNION ALL
    select 'EXISTS' FROM DUAL UNION ALL
    select 'SELECT' FROM DUAL
    select a.a,
           substr(s,REGEXP_instr(upper(s),a,1,column_value),length(a)) error_word,
           REGEXP_instr(upper(s),a,1,column_value) err_line
    from(
    select rownum n, q.*, rs.*, regexp_count(upper(q.s), rs.a) cnt from (    
    select
    'SELECT FINDING_LEVEL_ID,
           PROTOCOL_SETUP_ID,
           FLV_LAST_MODIFIED_BY,
           FLV_LAST_MODIFIED_ON
      froM empb
    Where exists (SELECT 1
              FROM dept a
             Where a.PROTOCOL_SETUP_ID = b.PROTOCOL_SETUP_ID
               AND PROTOCOL_LAST_MODIFIED_ON > to_date(ms_sra_get_max_date_fnc(''N'', ''SGMGBI''),''DD-MON-YYYY HH24:MI:SS''));' s
               from dual) q, RS) a, table(select collect(rownum) from dual connect by level <= a.cnt)
    where a != substr(s,REGEXP_instr(upper(s),a,1,column_value),length(a))
    A
    ERROR_WORD
    ERR_LINE
    WHERE
    Where
    121
    WHERE
    Where
    175
    FROM
    froM
    111
    EXISTS
    exists
    127
    Ramin Hashimzade

  • Pl/sql stored procedure code2 check the emial id is correct or not

    if the mail id is [email protected]@.com
    then how we do validations means
    there must be only one @
    i wnat all tghis type of validations 2 check the email id is correct or not?
    the procedure that i wnat to validate akll the validations

    This appears to be a duplicate of your existing thread
    pl/sql stored procedure for email id validations
    I'll answer there.
    Justin

  • Procedure that checks for a value in the database and returns related info

    Hi Everyone,
    I need to create a stored procedure that takes customer info(any of these fname,lname,id,email etc) and looks for it in the database and displays the customer info of that particular customer(kinda search engine).
    I have to use dynamic sql and sql injection.Can anyone give me a brief idea from where to start.Thankyou.

    create or replace procedure pro_customer(p_customer_id number, p_customer out customer%rowtype) is
    begin
    select *
    into p_customer
    from customer
    where customer_id = p_customer_id;
    end pro_customer;
    the names,keys and others are invented

  • Procedure to check data from different tables

    Hi
    I am trying to write a procedure to compare data from a table with another.
    Table 1
    ID Name Dept
    1 ABC Y
    2 DEF Z
    Table 2
    ID Dept
    1 Y
    2 Z
    Table 3
    Name ID
    1 ABC
    2 DEF
    I would like to compare each record data in Table 1 with data from different tables table2,table3 by matching ID,name.... Please help me with how I could start writing a procedure and also spool data that does not match from the table1 with other tables
    thanks
    Edited by: 890563 on Apr 30, 2012 10:34 AM

    Hope below helps you.
    CREATE TABLE TABLE1
    (    ID          VARCHAR2(10),
         FIRST_NAME  VARCHAR2(30),
         LAST_NAME   VARCHAR2(30),
         MIDDLE_NAME VARCHAR2(30)
    INSERT INTO TABLE1 VALUES('123456','testfirst','testlast','testmiddle');
    INSERT INTO TABLE1 VALUES('123457','testfirst1','testlast1','testmiddle1');
    CREATE TABLE TABLE1
    (    ID          VARCHAR2(10),
         FIRST_NAME  VARCHAR2(30),
         LAST_NAME   VARCHAR2(30),
         MIDDLE_NAME VARCHAR2(30)
    INSERT INTO TABLE2 VALUES('123456','testfirst','testlas','testmidd');
    INSERT INTO TABLE2 VALUES('123457','testfirst2','testlast1','testmiddle1');
    SELECT TABLE1.ID,
            -- Match First Name
         CASE WHEN TABLE1.FIRST_NAME != TABLE2.FIRST_NAME THEN TABLE1.FIRST_NAME ELSE NULL END TABLE1_FIRST_NAME,
         CASE WHEN TABLE1.FIRST_NAME != TABLE2.FIRST_NAME THEN TABLE2.FIRST_NAME ELSE NULL END TABLE2_FIRST_NAME,
            -- Match Middle Name
         CASE WHEN TABLE1.MIDDLE_NAME != TABLE2.MIDDLE_NAME THEN TABLE1.MIDDLE_NAME ELSE NULL END TABLE1_MIDDLE_NAME,
            CASE WHEN TABLE1.MIDDLE_NAME != TABLE2.MIDDLE_NAME THEN TABLE2.MIDDLE_NAME ELSE NULL END TABLE2_MIDDLE_NAME,
            -- Match Last Name
         CASE WHEN TABLE1.LAST_NAME != TABLE2.LAST_NAME THEN TABLE1.LAST_NAME ELSE NULL END TABLE1_LAST_NAME,
            CASE WHEN TABLE1.LAST_NAME != TABLE2.LAST_NAME THEN TABLE2.LAST_NAME ELSE NULL END TABLE2_LAST_NAME
    FROM  TABLE1, TABLE2
    WHERE TABLE1.ID = TABLE2.ID
    ID         TABLE1_FIRST_NAME  TABLE2_FIRST_NAME  TABLE1_MIDDLE_NAME TABLE2_MIDDLE_NAME TABLE1_LAST_NAME   TABLE2_LAST_NAME
    123456     NULL               NULL               testmiddle         testmidd           testlast        testlas
    123457     testfirst1         testfirst2         NULL               NULL               NULL            NULL
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Stored Procedure to check selection of name input box

    Hello all,
    I have a query with which the user (using Reporting Services) will need to input the last name, and first name, or date of birth, or SSN.  Since the table contains a large amount of data and accessing data from three tables, the process is slow. 
    How can I speed up this process?  Is there some way to create a SP to test the different scenarios (i.e., last name and first name, or first name and birthdate, or last name and SSN, etc.)?  To check each scenario that a user may combine will require
    a large query.
     In the report, the user will have the option of selecting an employee using (ex. 1 and 2, or 1 and 2 or 3 or 4;   1 or 3;  or 3; or 4) . If I can test this using a SP that would be much easier than having
    to duplicate the query for each scenario.  See example below.
    Thanks in advance for any assistance given!
    declare @lastname varchar (40)
    declare @firstname varchar (40)
    declare @SSN varchar (11)
    declare @birthdate varchar (25)
    set @lastname = 'lastname'
    set @firstname  ='firstname '
    set @SSN ='SSN '
    set @birthdate ='birthdate'
    (ssn
    LIKE '%'
    + @ssn+ '%'
    and @lastname=
    '' and @birthdate
    = '' and @
    = '')
    OR
    (@ssn
    = ''
    AND lastname LIKE
    '%' + @lastname
    + '%' AND @birthdate
    = ''
    AND @firstname = '')
    OR
    (@ssn=
    '' AND @lastname
    = '' AND birthdate
    = @birthdate AND @firstname
    = '')
    OR
    (@ssn
    = ''
    AND @lastname = ''
    AND @birthdate =
    '' AND firstname
    LIKE '%' + @firstname
    + '%')

    Well 1st thing... The use of leading wild cards is making your queries non-sargable (can't use indexes) which is a major performance hit.
    As far as only searching the applicable table. That's easy enough to control by using IF blocks.
    IF @LastName IS NOT NULL AND @FirstName IS NOT NULL BEGIN .... END ELSE IF @LastName IS NOT NULL AND @SSN IS NOT NULL BEGIN .... END ELSE.... and so on.
    Jason Long

Maybe you are looking for