Issue converting the following query to text.

Hello guys, I'm trying to convert the following query to text and to use PRINT so that it returns theresult in the picture as output, help would be appreciated, thanks :)SELECT EventName, EventDate
FROM EventTable
ORDER BY EventDate DESC;

This is an example, As I said it is not a good approach
set nocount on
declare @tab table(id int,txt varchar(100));
declare @txt varchar(1000);
declare @count int;
insert into @tab
values(1,'Text 1'),(2,'Text 2'),(4,'Text 4');
select *,RN=ROW_NUMBER()OVER(ORDER BY (SELECT NULL)) into #temp from @tab
select @count=@@ROWCOUNT;
while @count>0
begin
select @txt =right(replicate(' ',50)+convert(varchar(50),ID),50) +
right(replicate(' ',50)+convert(varchar(50),txt),50)
from #temp where RN=@count
set @count=@count-1
print @txt
end
drop Table #temp
Satheesh
My Blog |
How to ask questions in technical forum

Similar Messages

  • How to convert the following query to sql server 2005

    hi
    i have the following query in ms access and i want to convert it into sql server 2005 express edition
    SELECT iif(Max(BNo) is null,1,Max(BNo)+1) AS BNo from ( SELECT iif(Max(Product.BNo) is null,0,Max(Product.BNo)) AS BNo FROM Product union all SELECT iif(Max(grndetail.BNo) is null,0,Max(grndetail.BNo)) AS BNo FROM grndetail UNION ALL SELECT iif(Max(srdetail.BNo) is null,0,Max(srdetail.BNo)) AS BNo FROM srdetail ) as t
    how to do this

    The construct involving case when MAX sounds suspicious. Can you explain what the query is supposed to be doing, the structure of your table, then we can re-write it?
    E.g. if you provide your table, some data and desired result, you'll get better answer than direct translation of this suspicious query.
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles

  • I have a new iPhone 5 and receive the following message when texting some people within my contacts.  Message sent using invalid number of digits please resend using 10 digit number or valid short code Msg:2114

    I have a new iPhone 5 and receive the following message when texting some people within my contacts.  Message sent using invalid number of digits please resend using 10 digit number or valid short code Msg:2114. Online I found a discussion that stated i needed to delete contact and re-add. I have done that to no avail. Any ideas?

    I had the same issue with the iPhone 6 and tried everything!  I now understand that at some point I stored a number for a contact without including the area code and sent a text message.  So, to correct the issue, you must literally "erase" all references to the contact, not just the number.  Deleting the contact and entering a new one is not enough because the iPhone stores references to that number in multiple places.  The steps below worked and are very simple:
    1) On the contact screen, delete everything stored for that number.  You can't just edit the contact to fix the problem, so write down or record the info somewhere before you complete this step.  Choose edit and then select DELETE to eliminate the entire contact which means home, work, cell, email address, etc.
    2) Delete the entire string of messages you sent to that number.  That's every single message...
    3) Now delete the entire string of invalid 2114 messages you received after your text(s) failed.
    4) Finaly, remove the contact from FAVORITES if you saved it that way. 
    5) To validate that all this worked, simply go to the keypad or contact screen and enter the number associated with the contact to verify successful removal.  I used the keypad and dialed to confirm.  If the contact number still shows up, you need to go back and recheck your steps.  Trust me, I had to do this a few times.
    Several posts suggested that you should  reset and turn off your phone.  After following these steps, it was not necessary for me to reset or turn off my device. 
    is there a much faster way to achieve the same results?  Probably, but this was safe for an iPhone novice and may help you avoid inadvertently deleting other contacts or replacing factory settings that you need.  

  • The following query failed: GetUserProfileByName - with the wrong username

    I have 2 users (out of 800), who run into this issue on occasion. Their username is 'fccs\user1' in the profile db, and in every UserInfo table in the system. But when they try to go to certain sites or open an infopath form, this error gets thrown:
    The following query failed: GetUserProfileByName (User: FCCS\[email protected], Form Name: Template, IP: , Connection Target: , Request: http://fccsteams/sites/DataManagement/Tasks/Lists/Tasks/Folders1.aspx?RootFolder=/sites/DataManagement/Tasks/Lists/Tasks/2013/11&, Form ID: urn:schemas-microsoft-com:office:infopath:list:-AutoGen-2013-08-05T23:14:53:458Z Type: DataAdapterException, Exception Message: The remote server returned an error: (500) Internal Server Error.  Operation Failure ---> Access Denied: To create a user profile, you must be an administrator, or create your own profile and have personal features rights.  UnauthorizedAccessAccess Denied: To create a user profile, you must be an administrator, or create your own profile and have personal features rights. The remote server returned an error: (500) Internal Server Error.)
    Notice how the username is now the entire email address and not just the username. I have no idea why it thinks that that is their username. Any ideas?

    Hi,
    According to your post, my understanding is that you got query failed error.
    Melick had written a blog said that the form access the user profile web service (Userprofileservice.asmx) using  UDC
    file.
    You can check whether the UDC connection was still pointing to root site.
    You can change this file to match with the sub site collection. Otherwise there may be a cross domain access issue.
    There are similar threads for your reference.
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/9c2f7f4c-0fa9-43bd-94b1-1d7075e35841/5566-error-with-getuserprofilebyname-and-infopah-browser-forms-using-claims-based-authentication
    http://social.msdn.microsoft.com/Forums/en-US/49753330-40c0-4327-9a9b-2c3304a74e67/sharepoint-infopath-and-populating-forms-with-ad-data?forum=sharepointcustomizationlegacy
    Thanks & Regards,
    Jason 
    Jason Guo
    TechNet Community Support

  • Can I rewrite the following query without using Row_number() function ??!!

    Hello every one, can I rewrite the following query without using the 'ROW_NUMBER() OVER ' part.
    The query is supposed to pull out the records whose CODE is not NULL and has most
    recent date for UPDATE_DATE . The reason I wanted to do this is, When I embed this query
    in between many other queries along with JOINs, My oracle server is unable to execute. So, I thought
    its better to supplant 'ROW_NUMBER() OVER ' logic with something else and try it. .
    SELECT a.* FROM
    (SELECT b.*, ROW_NUMBER() OVER (PARTITION BY b.PIDM
    ORDER BY b.UPDATE_DATE DESC) AS Rno
    FROM
    SELECT *
    FROM SHYNCRO WHERE CODE IS NOT NULL
    )b
    )a
    WHERE a.Rno = 1

    Hi,
    You didn't write over 150 lines of code and then start testing it, did you?
    Don't.
    Take baby steps. Write as little as pssiblem test that. Debug and test again until you have something that does exactly what you want it to do.
    When you have somehting that works perfectly, take one baby step. Add a tiny amount of code, maybe 1 or 2 lines more, and test again.
    When you do get an error, or wrong results, you'll have a much better idea of where the problem is. also, you won't be building code on a flimsy foundation.
    If you need help, post the last working version and the new version with the error. Explain what you're trying to do in the new version.
    The error message indicates line 133. It looks like line 133 of your code is blank. Does your front end allow completely blank lines in the middle of a query? SQL*Plus doesn't by default; you have to say
    SET  SQLBLANKLINES  ONto have a completely blank line in SQL*Plus. (However, lines containing nothing but at commnet are always allowed.)
    You may have noticed that this site normally doesn't display multiple spaces in a row.
    Whenever you post formatted text (such as indented code) on this site, type these 6 characters:
    \(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.
    The 4 people who posted small code fragments for you to read all did this.  It would be so much easier for people to read your humongeous query if it were formatted.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to add a receipt number in the following Query for PO Report

    Hi Guys,
    I need a help regarding following query.
    Its a PO report for 11.5.10.2
    select distinct pv.segment1 supplier_number,
    pv.vendor_name supplier_name,
    pha.segment1 po_number,
    pha.revision_num revision_num,
    pha.authorization_status po_status,
    to_char(pha.creation_date, 'DD/MM/YYYY') creation_date,
    pha.currency_code currency_code,
    pla.sum_amount_ordered sum_amount_ordered,
    pda.sum_quantity_ordered sum_quantity_ordered,
    pda.sum_amount_received sum_amount_received,
    pda.sum_quantity_received sum_quantity_received,
    (pla.sum_amount_ordered - pda.sum_amount_received) sum_accrued, --AVI
    ( pda.sum_quantity_ordered - pda.sum_quantity_received) quantity_accrued, --AVi
    to_char(rsl.date_receipt, 'DD/MM/YYYY') date_receipt,
    -- rsl.receipt_num receipt_number,
    ppa.segment1 project_code, ppa.project_status_code, --10.0.0.4
    aia.invoice_num invoice_num,
    aia.invoice_date invoice_date, --AVI 
    aia.creation_date invoice_creation_date, --AVI 
    aia.amount invoice_amount_allocated_to_po, --AVI
    pla.purchase_basis,
    pla.category_id,
    -- pda.item_description,
    haou.name organisation, --10.0.0.3
    pda.sum_quantity_billed sum_quantity_billed , --10.0.0.3
    gcc1.CONCATENATED_SEGMENTS,
    gcc2.CONCATENATED_SEGMENTS
    from po_headers_all pha,
    po_vendors pv,
    pa_projects_all ppa,
    hr_all_organization_units haou,
    (select po_header_id,
    sum(quantity * unit_price) sum_amount_ordered,
    org_id,
    purchase_basis,
    category_id
    -- pla.item_description,
    from po_lines_all
    group by po_header_id, org_id
    , purchase_basis,
    category_id
    -- pla.item_description
    ) pla,
    (select pla.po_header_id,
    pda.project_id,
    sum(pda.quantity_ordered) sum_quantity_ordered,
    sum(pda.quantity_delivered * pla.unit_price) sum_amount_received,
    sum(pda.quantity_delivered) sum_quantity_received,
    sum(pda.quantity_billed) sum_quantity_billed, --10.0.0.3
    accrual_account_id
    from po_distributions_all pda, po_lines_all pla
    where pla.po_line_id = pda.po_line_id
    group by pla.po_header_id, pda.project_id,accrual_account_id
    ) pda,
    (select po_header_id, charge_account_id,
    -- rsh.receipt_num,
    min(rsl.creation_date) date_receipt
    from rcv_shipment_lines rsl
    where rsh.SHIPMENT_HEADER_ID=rsl.SHIPMENT_HEADER_ID
    group by po_header_id,charge_account_id
    ) rsl,
    (select distinct aia.invoice_num, pda.po_header_id , aia.invoice_date --10.0.0.3
    , aia.creation_date , sum(aida.amount) amount
    from po_distributions_all pda,
    ap_invoice_distributions_all aida,
    ap_invoices_all aia
    where pda.po_distribution_id = aida.po_distribution_id(+)
    and aia.invoice_id(+) = aida.invoice_id
    Group by
    aia.invoice_num, pda.po_header_id , aia.invoice_date --10.0.0.3
    , aia.creation_date) aia,
    (select haou2.organization_id, haou2.name
    from fnd_flex_value_sets ffvs,
    fnd_flex_value_norm_hierarchy ffvnh,
    fnd_flex_values_vl ffvv,
    hr_all_organization_units haou1,
    FND_FLEX_VALUE_CHILDREN_V ffvcv,
    hr_all_organization_units haou2
    where ffvs.FLEX_VALUE_SET_NAME = 'CAP_CODE_BU'
    and ffvs.FLEX_VALUE_SET_ID = ffvnh.flex_value_set_id
    and ffvnh.parent_flex_value like 'PO%'
    and ffvv.FLEX_VALUE_SET_ID = ffvnh.flex_value_set_id
    and ffvv.FLEX_VALUE between ffvnh.child_flex_value_low and ffvnh.child_flex_value_high
    and substr(haou1.name, 1, Instr(haou1.name, '-')) =
    substr(ffvv.DESCRIPTION, 1, Instr(ffvv.DESCRIPTION, '-'))
    and haou1.organization_id = fnd_global.org_id
    and ffvcv.parent_flex_value = ffvnh.parent_flex_value
    and ffvcv.flex_value_set_id = ffvs.flex_value_set_id
    and substr(haou2.name, 1, Instr(haou2.name, '-')) =
    substr(ffvcv.DESCRIPTION, 1, Instr(ffvcv.DESCRIPTION, '-'))
    union --10.0.0.1
    select f.organization_id, f.name --10.0.0.1
    from hr_all_organization_units f --10.0.0.1
    where f.organization_id = fnd_global.ORG_ID --10.0.0.1
    ) bu
    , po_line_locations_all plla --10.0.0.4
    , gl_code_combinations_kfv gcc1
    ,gl_code_combinations_kfv gcc2
    where pv.vendor_id = pha.vendor_id
    and pla.po_header_id = pha.po_header_id
    and pda.po_header_id = pha.po_header_id
    and pha.po_header_id = rsl.po_header_id(+)
    and pda.project_id = ppa.project_id(+)
    and pha.po_header_id = aia.po_header_id(+)
    and aia.po_header_id = pha.po_header_id
    and pla.org_id = haou.organization_id
    and pha.authorization_status in ('APPROVED', 'OPEN')
    and plla.po_header_id = pha.po_header_id --10.0.0.4
    and plla.closed_code in ('APPROVED', 'OPEN', 'CLOSED FOR INVOICE', 'CLOSED FOR RECEIVING', 'CANCELLED') --10.0.0.4
    and bu.organization_id = haou.organization_id
    AND gcc1.code_combination_id = pda.accrual_account_id
    AND gcc2.code_combination_id =rsl.CHARGE_ACCOUNT_ID
    In the following query I have commented receipt_num using the table rcv_transaction_headers.
    If I uncomment it the query results huge number of unexpected report.
    How can I add receipt number to the following query?
    Should I use rcv_transactions. If yes, what would be the join conditions.
    Kindly help as its urgent.
    Thanks in advance.
    Regards
    Avijit

    Sandeep is correct. I don't have time to tell you the correct query, but mine is something like this based on Sandeep's information:
    SELECT rsh.receipt_num
    FROM   rcv_transactions      rcvt,
           po_lines_all          pla,
           rcv_shipment_headers  rsh
    WHERE  rcvt.shipment_header_id   = rsh.shipment_header_id
    AND    rcvt.PO_LINE_ID          = pla.PO_LINE_ID
    AND    pla.item_id              = (select distinct inventory_item_id
    from mtl_system_items
    where segment1 = '1216107-2')

  • Need help in the following query

    Hi ,
    I have the following query to pull out data for a particular timeperiod( campaign)
    select
    da.acct_nr,smas.mrkt_id,smas.fld_sls_cmpgn_perd_id,smas.acct_key,smas.upln_acct_key,smas.awrd_sls_amt,smas.fld_net_sls_amt
    ,smas.stf_ind,da1.acct_nr,
    smas.fld_sls_cmpgn_perd_id,smas.acct_key,smas.upln_acct_key,smas.awrd_sls_amt,smas.fld_net_sls_amt
    ,smas.stf_ind,da1.acct_nr,prev.*
    From cdw.sum_mrkt_acct_sls smas
    join codi.dim_acct da
    on (smas.mrkt_id = da.mrkt_id and smas.acct_key = da.acct_key)
    join codi.dim_acct da1
    on (smas.mrkt_id = da1.mrkt_id and smas.UPLN_acct_key = da1.ACCT_KEY)
    where smas.acct_key in
    select dwnln_acct_key from codi.dim_ldrshp_genlgy
    where mrkt_id = 66 and fld_sls_cmpgn_perd_id = 20100304
    and root_upln_acct_key = (select acct_key from codi.dim_acct where acct_nr = '0032622' and mrkt_id = 66)
    and
    smas.mrkt_id = 66
    and smas.fld_sls_cmpgn_perd_id = 20100304
    and smas.sls_org_key <> -100
    order by 1
    So this query will pull out data for campaign 20100304
    No i want to modify the query to pull out data for 3 such campaigns.
    for a smas.acct_key
    so data will
    smas.acct_key all the data for 1st campaign , all the data for 2nd campaign. all the data for 3rd campaign
    Could you please help in modifying this query.
    Thanks

    How about this ??
    select da.acct_nr,
           smas.mrkt_id,
           smas.fld_sls_cmpgn_perd_id,
           smas.acct_key,
           smas.upln_acct_key,
           smas.awrd_sls_amt,
           smas.fld_net_sls_amt,
           smas.stf_ind,
           da1.acct_nr,
           smas.fld_sls_cmpgn_perd_id,
           smas.acct_key,
           smas.upln_acct_key,
           smas.awrd_sls_amt,
           smas.fld_net_sls_amt,
           smas.stf_ind,
           da1.acct_nr,
           prev.*
      From cdw.sum_mrkt_acct_sls smas
      join codi.dim_acct da on (smas.mrkt_id = da.mrkt_id and
                               smas.acct_key = da.acct_key)
      join codi.dim_acct da1 on (smas.mrkt_id = da1.mrkt_id and
                                smas.UPLN_acct_key = da1.ACCT_KEY)
    where smas.acct_key in (select dwnln_acct_key
                               from codi.dim_ldrshp_genlgy
                              where mrkt_id = 66
                                and fld_sls_cmpgn_perd_id in( 20100304,20100305,20100306)
                                and root_upln_acct_key =
                                    (select acct_key
                                       from codi.dim_acct
                                      where acct_nr = '0032622'
                                        and mrkt_id = 66))
       and smas.mrkt_id = 66
       and smas.fld_sls_cmpgn_perd_id in( 20100304,20100305,20100306)
       and smas.sls_org_key - 100
    order by 1

  • Can u write the following query without using group by clause

    select sp.sid, p.pid, p.name from product p, supp_prod sp
    where sp.pid= p.pid and
    sp.sid = ( select sid from supp_prod group by sid
    having count(*) =(select count(*) from product));
    thru this, we retrieving all the products delivered by the supplier.
    Can you write the following query without using the group by clause

      select sp.sid, p.pid, p.name
        from product p, supp_prod sp
       where sp.pid= p.pid the above query will still retrieve all the products supplied by the supplier. sub-query is not necessary.
    maybe if you can post some sample data and output will help us understand what you want to achieve.

  • Problem in finding Exact result by using the following Query

    Hello,
    I am finding difficulty in producing the required result by using the following Query in Reports 6i
    (Note: - The query actual output and the required output are as follows: -)
    SELECT
    DISTINCT
    SH.S_HEAD_CODE,
    B.BILL_ID,
    B.SANCTION_DATE,
    E.EMP_NAME,
    E.EMP_DESIGNATION,
    B.TOTAL_BILL,
    NVL((SH.INITIAL_ALLOCATION-B.TOTAL_BILL), 0) BALANCE
    FROM BILL B, PARAMETERS P,SUB_HEAD SH, EMPLOYEES E, BILL_DETAIL BD
    WHERE
    SH.S_HEAD_CODE=B.S_HEAD_CODE
    AND B.S_HEAD_CODE=BD.S_HEAD_CODE
    AND B.EMP_ID_NO=E.EMP_ID_NO
    AND B.BILL_ID=BD.BILL_ID
    The Output of the above query is as follows: -
    Let say we have Total Amount Sanctioned Rs. 15,000,00/-
    Name Total Bill (Rs.) Balance (Rs.)
    Sohail 7147 1492853
    Saqib 2131 1497869
    Amir 6802 1493198
    Shafiq 1214 1498786
    Note:- In the above output the above query is subtracting the current balance from Total Sanctioned Amount (Rs. 1500000) each time, but
    it should actually subtract the current bill amount from the previous balance like the below said result.
    Name Total Bill (Rs.) Balance (Rs.)
    Sohail 7147 1492853 {Previous Balance - Current Bill Amount (1500000-7147) }........ The previous balance was actual amount Rs. 1500000
    Saqib 2131 1490722 {Previous Balance - Current Bill Amount (1492853 - 2131)}
    Amir 6802 1483920 {Previous Balance - Current Bill Amount (1490722 - 6802)}
    Shafiq 1214 1482706 {Previous Balance - Current Bill Amount (1483920 - 1214)}
    Results Continue...........................
    Please help me to solve this problem.
    Thank you in advance

    just check if this meets your requirements,
    SQL>
    SQL> With t As
      2  (
      3  Select 'Sohail' c1 ,7147 c2 ,1492853 c3 From dual Union All
      4  Select 'Saqib'   ,2131 ,1497869         From dual Union All
      5  Select 'Amir'    ,6802 ,1493198         From dual Union All
      6  Select 'Shafiq' ,1214 ,1498786          From dual
      7  )
      8  Select c1,
      9         c2,
    10         prv_amt - c2 current_amt
    11  From
    12  (
    13  Select c1,
    14         c2,
    15         c3,
    16         lag(c3,1,1500000) over(Order By c3) prv_amt
    17  From t
    18  );
    C1             C2 CURRENT_AMT
    Sohail       7147     1492853
    Amir         6802     1486051
    Saqib        2131     1491067
    Shafiq       1214     1496655
    SQL>

  • How Can I make the following query faster

    Hi Guru
    I want your valuable suggestion to make the following query faster.I did not write all required columns list. I gave here all those columns where I have conditon like decode,case when,or subquery
    (SELECT CASE WHEN REPORTED_BY IS NULL THEN
              (SELECT INITCAP(EMP_NAME) FROM HR_EMP WHERE EMP_NO = M.EMP_NO_RADIO)
         ELSE (SELECT INITCAP(EMP_NAME) FROM HR_EMP WHERE EMP_NO = M.REPORTED_BY) END RADIOLOGIST_NAME,
         (SELECT TEAM_NAME FROM DC_TECHTEAMMST WHERE TEAM_NO = M.GROUP_NO) GROUP_NAME,
         CASE WHEN M.RESULT_ENTRY_LOCK_BY IS NOT NULL THEN 'R'
    WHEN M.REPORT_DONE = 'D' THEN 'D'
    WHEN M.REPORT_DONE = 'P' THEN 'P'
    WHEN M.REPORT_DONE = 'F' THEN 'F'
         WHEN NVL(M.IMG_CAPTURED,'X') NOT IN ('B','Y') OR M.QA_RESULT = 'F' THEN 'S'
    WHEN NVL(M.IMG_CAPTURED,'X') IN ('B','Y') AND NVL(M.QA_RESULT,'X') NOT IN ('B','P') THEN 'Q'
         wHEN NVL(M.IMG_CAPTURED,'X') IN ('B','Y') AND NVL(M.QA_RESULT,'X') IN ('B','P') THEN 'C'
    END STATUS,
         (SELECT DECODE(NVL(V.DELIVERY_STATUS,'N'),'E',3,'U',2,1)
              FROM FN_VOUCHERCHD V WHERE V.VOUCHER_NO = M.VOUCHER_NO AND V.ITEM_NO = M.TEST_NO) DELIVERY_STATUS,
         trunc((start_time-order_end)*24,0)||' hr'||':'||
         decode(length(trunc(to_char(MOD((M.start_time-M.order_end)*24,1)*60),0)),2,to_char(trunc(to_char(MOD((M.start_time-M.order_end)*24,1)*60),0))
              ,1,to_char('0'||trunc(to_char(MOD((M.start_time-M.order_end)*24,1)*60),0)))||' mi' duration_order_capture,
         DECODE(R.CONFIDENTIAL_PATIENT,'Y','*',NVL(R.NAME,R.name_lang_name||' '||R.name_lang_fname)) PAT_NAME,
         FNC_PATIENTAGE(R.REG_NO,'',R.CONFIDENTIAL_PATIENT) pat_age,
         DECODE(R.CONFIDENTIAL_PATIENT,'Y','*',R.PATIENT_SEX) PAT_SEX
    FROM DC_MODALITYAPPOINTMENT M,DC_TESTMST T,OP_REGISTRATION R
    WHERE M.ACCESSION_NO IS NOT NULL AND NVL(M.CANCEL_FLAG,'N') = 'N'
    AND (NVL(T.SP_GEN,'S') = 'S' OR NVL(M.DOC_REQ_GEN,'N') = 'Y')
    AND M.TEST_NO IS NOT NULL AND M.TEST_NO = T.TEST_NO AND M.REG_NO = R.REG_NO)
    How can I make the above query faster.
    Query condition or indexing whatever is preferable please guide me.
    The approximate data of tables
    DC_MODALITYAPPOINTMENT 2,000,000
    A lot of updating is going on some columns of this table.all columns are not in the select list, Insertion is happend in batch process by back-end trigger of another table.
    Primary key based one column,
    OP_REGISTRATION 500,000
    Daily insertion on this table around 500 records,updation is not much.
    Primary key based one column 'reg_no'
    DC_TESTMST
    Total records of this table not more than 1500.This is setup table. Insertion and updation is not much on this table also
    I have to create a view based on this query .
    and I have to create another view to serve another purpose.
    In the 2nd view I need this query as well as I need another query by using union all operator based on a table(dc_oldresult)
    which have 1,600,000 records.There is no DML on this table
    SELECT      NVL((SELECT USER_DEFINE_TEST_NO FROM DC_TESTMST WHERE TEST_NO = SV_ID AND ROWNUM = 1 ),SV_ID) USER_D_EXAM_NO,
    (SELECT TEST_TYPE FROM DC_TESTMST WHERE TEST_NO = SV_ID AND ROWNUM = 1 ) EXAM_TYPE,
         NVL((SELECT TEST_NAME FROM DC_TESTMST WHERE TEST_NO = SV_ID AND ROWNUM = 1),'Exam Code: '||sv_id) EXAM_NAME,
         (SELECT PAT_NAME FROM OP_REGISTRATION WHERE REG_NO = HN) PATIENT_NAME,
         (SELECT PAT_AGE FROM OP_REGISTRATION WHERE REG_NO = HN) PATIENT_AGE,
         (SELECT PAT_SEX FROM OP_REGISTRATION WHERE REG_NO = HN) PATIENT_GENDER
    FROM DC_OLDRESULT
    WHERE HN IS NOT NULL AND SV_ID IS NOT NULL AND UPPER(ACTIVE) = 'TRUE'
    Should I make join DC_OLDRESULT, OP_REGISTRATION and DC_TESTMST? or The eixisting subquery is better?
    I use OP_REGISTRATION and DC_TESTMST in both query
    Thanks in advance
    Mokarem

    When your query takes too long ...

  • Write the following query using JOIN keyword ?

    Qest:
    Write the following query using JOIN keyword ?
    select ID_category from category_master X
    where Exist(select 1 from sub_category Y where
    X.ID_category=Y.ID_category)Edited by: 799660 on Oct 3, 2010 6:05 AM

    select  X.ID_category
      from  category_master X join (select distinct ID_category from sub_category) Y
             on (X.ID_category=Y.ID_category)
    /SY.

  • Is there any way to convert the selected rows to text in javascript??

    Hi All,
    I have place some word file to indesign cs 5.5 it is almost in one table, i need to separate the text from the real tables, Is there any way to convert the selected rows to text in javascript??
    If there is no way to make that, any one can help me to make a script to cut the selected rows and place it in privies pointer of the table to make it independent table and after that convert it to text ?

    This insert the rows contents after the table instead of being before:
    for (var r = app.selection.length - 1; r >= 0; r--) {
        for (var t = app.selection[r].rows.length - 1; t >= 0; t--) {
            for (var u = app.selection[r].rows[t].cells.length - 1; u >= 0; u--) {
                for (var c = app.selection[r].rows[t].cells[u].paragraphs.length - 1; c >= 0; c--) {
                    app.selection[r].rows[t].cells[u].paragraphs[0].move (LocationOptions.AFTER, app.selection[r].rows[t].parent.parent.storyOffset.parent.insertionPoints.nextItem(app.se lection[r].rows[t].parent.parent.storyOffset));
                    if (c != 0)
                        app.selection[r].rows[t].parent.parent.storyOffset.parent.insertionPoints.nextItem(app.se lection[r].rows[t].parent.parent.storyOffset).contents += "\r";
                if (u != 0) {
                    app.selection[r].rows[t].parent.parent.storyOffset.parent.insertionPoints.nextItem(app.se lection[r].rows[t].parent.parent.storyOffset).contents += "\t";
                else {
                    app.selection[r].rows[t].parent.parent.storyOffset.parent.insertionPoints.nextItem(app.se lection[r].rows[t].parent.parent.storyOffset).contents += "\r";
    for (var r = 0; r < app.selection.length; r++) {
        for (var t = app.selection[r].rows.length - 1; t >= 0; t--) {
            app.selection[r].rows[t].remove ();

  • Launchctl: Please convert the following to launchd

    Hi,
    I'm running 10.5.1, and it's taking a long time for my Mac to start up. I looked in console and found
    11/28/07 10:18:32 AM com.apple.launchctl.Aqua[91] launchctl: Please convert the following to launchd: /etc/machinit_peruser.d/PCIESlotCheck.plist
    11/28/07 10:18:42 AM com.apple.launchctl.Aqua[91] launchctl: Please convert the following to launchd: /etc/machinit_peruser.d/RemoteUI.plist
    11/28/07 10:18:44 AM com.apple.launchd[88] (0x101060.PCIESlotCheck) Failed to check-in!
    I tried using PListEdit Pro to see what might be offending launchd, but I'm at a loss. Does anyone know how I can get those plists to stop choking launchd? Can I just delete them?
    Also, copying messages from Console is a pain now. Is there a way in Leopard to click and drag to select in Console like we used to?
    Thank you!
    Libby

    Sorry, I don't understand these things well enough to explain it, but the gist of it is that in the past, many mechanisms (including 'mach_init') were used to start processes for services, etc. during startup, but since Tiger, Apple has been working toward consolidating them so that eventually 'launchd' will presumably take over everything. If you are really interested, there is some documentation on the startup process here:
    http://developer.apple.com/documentation/MacOSX/Conceptual/BPSystemStartup/index .html
    Regarding the files though, if you did a clean install, it seems odd that they are there - I did an upgrade install, and the files you mentioned weren't present on my system (the "LaunchAgents" versions were). It seems odd to me that there would be that redundancy in a fresh install, especially if it is generating errors. As long as the launchd counterparts are present, it will probably be safe to remove the 'mach_init' ones, but as before, back them up just in case.
    Specifically, you can try to match a given file to service by searching the web to help you decide if it is something you want mess with it. For starters, I found this page by searching for the file names you mentioned in the earlier post:
    http://www.macgeekery.com/gspot/2006-12/turningoff_unneededservices

  • Message console: Please convert the following to launchd: /etc/mach_init...

    How can I handle with this message console: com.apple.launchctl.Aqua[126]: launchctl: Please convert the following to launchd: /etc/machinit_peruser.d/RemoteUI.plist ???
    I can't found the /etc/ folder to try some posted solutions!!!

    this is is a system message for apple programmers. it can be safely ignored. don't even try to do anything about it yourself. you can't and you shouldn't.
    Message was edited by: V.K.

  • How do i convert the following case statement to a table and still implement it in the store procedure.

    if @CustNo = '0142'          begin              insert #custnos (CustNo, ClientNo)              values ('0142', '1100')                      ,('0142', '1200')                      ,('0142', '1201')                      ,('0142', '1700')                      ,('0142', '1602')                      ,('0142', '1202')                      ,('0142', '1603')                      ,('0142', '2002')          endstore procUSE ODSSupport
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    SET ANSI_NULLS ON
    GO
    if exists (select * from dbo.sysobjects where id = object_id(N'dbo.pr_Load_PASOArgusClaims_Work') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
    BEGIN
    drop procedure dbo.pr_Load_PASOArgusClaims_Work
    IF OBJECT_ID ('dbo.pr_Load_PASOArgusClaims_Work') IS NOT NULL
    PRINT '<<< FAILED DROPPING PROCEDURE dbo.pr_Load_PASOArgusClaims_Work >>>'
    ELSE
    PRINT '<<< DROP PROCEDURE dbo.pr_Load_PASOArgusClaims_Work >>>'
    END
    GO
    CREATE PROC dbo.pr_Load_PASOArgusClaims_Work
    @BatchNo varchar(7) = null,
    @CustNo char(4) = null,
    @NewBatchNo varchar(7) = null
    AS
    /* Object dbo.pr_Load_PASOArgusClaims_Work 2006234 */
    -- SSR# : 2242
    -- Date : 12/23/2005
    -- Author : Roxy Newbill
    -- Description : Add new PASO BCAT 1602
    -- SSR# 1932 - 2/22/2006 SEN - Add logic to include only ArgusCustNo - 0142
    -- and change PharmacyClaim.ProcessDate to DateWritten
    -- SSR# : 2419
    -- Date : 08/22/2006
    -- Author : Betty Doran
    -- Description : PASO reports project
    -- Correct mapping of Dispense fee amt from 'AmtProfFee' to 'DispenseFee' -
    -- Mapping changed by Argus - did not inform PHP. Used in calcs for mClaimTotAmtCharge and
    -- mClaimAmtAllowed fields.
    -- SSR# : 2496
    -- Date : 06/27/2007
    -- Author : Roxy Newbil
    -- Description : PASO Reporting Project
    -- Add data load for new columns: Prescription No, Drug Name, NDC
    -- SSR# : PEBB PROJECT
    -- Date : 10/13/2009
    -- Author : Tj Meyer
    -- Description : Add BCAT 1201 for new PEBB business--
    -- SSR# : 132707
    -- Date : 12/17/2009
    -- Author : Terry Phillips
    -- Description : PASO Reporting Project
    -- Fix data length issues for Argus_SubGroupId,Argus_PlanCode,vchParticipantId,
    -- vchProviderId
    -- SSR# : 3253
    -- Date : 03/28/2011
    -- Author : Susan Naanes
    -- Description : PrescriptionNo increased in size from 7 to 12 characters
    -- SSR# : SPOCK project
    -- Date : 08/09/2012
    -- Author : Raymond Beckett
    -- Description : Modifed to bring in RxKey from PharmacyClaim instead of using identity value for iRecId
    -- Also, modified to load any new batches since last batch loaded into PASOArgusClaims
    -- if @BatchNo not supplied
    -- Various 'fixes'
    -- - removed grouping from initial query due to unique grouping caused by BatchNo, ClaimNumber, ClaimType
    -- SSR# : TFS 5264 - Premera Remediation -(3997)
    -- Date : 12/21/2012
    -- Author : Satish Pandey
    -- Description : Add BCATs 1202 and 1603 to the Where clause selecting pharmclm.ArgusClientNo as BCAT
    -- SSR# : TFS 10286
    -- Date : 1/15/2014
    -- Author : Raymond Beckett
    -- Description : Add HRI Customer Number and BCAT's. Also add Customer Number and alternate batchno to parameters
    -- Only use '@NewBatchNo' if adding data from missed custno and the batchno already exists in PASOArgusClaims
    -- ITSM Ticket : 1800925
    -- Date : 4/15/2014
    -- Author : Roxy Newbill
    -- Description : Silverton Hospital had new BCAT (2002) with start of 2014 business. This was never accomodated for
    -- Adding this BCAT in so that we can start capturing these claims (Note, special insert being done to capture
    -- all BCAT 2002 claims prior to this fix.)
    -- ITSM Ticket : TFS 14587 -Intel BCAT Remediation
    -- Date : 08/14/2014
    -- Author : Andrew Omofonma
    -- Description : Added BCAT's (1604,& 2103) for Intel
    SET NOCOUNT ON
    DECLARE @iCount int
    create table #tmpArgusWork (
    iRecId int,
    BatchNo varchar (7) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
    BatchDateTime datetime NULL ,
    BatchStatus varchar (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
    ReadyDateTime datetime NULL ,
    Argus_GroupId varchar (10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
    Argus_SubGroupId varchar (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
    Argus_ClassId varchar (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
    Argus_PlanCode varchar (8) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
    Argus_BusinessCategory varchar (8) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
    FacetsClaimSubType varchar (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
    PASOClaimType varchar (20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
    vchClaimNumber varchar (14) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
    dtPaidDate datetime NULL ,
    dtProcessDate datetime NULL ,
    dtServiceDate datetime NULL ,
    vchParticipantId varchar (14) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
    vchProviderId varchar (12) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
    vchProviderName varchar (55) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
    mClaimTotAmtCharge money NULL ,
    mClaimAmtDiscount money NULL ,
    mClaimAmtAllowed money NULL ,
    mClaimAmtDenied money NULL ,
    mClaimAmtDeduct money NULL ,
    mClaimAmtCoinsurance money NULL ,
    mClaimAmtCopay money NULL ,
    mClaimAmtPaid money NULL ,
    PASO_GroupId varchar (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
    PASO_SubGroupId varchar (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
    PASO_ClassID varchar (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
    PASO_PlanCode varchar (8) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
    PASO_BusinessCategory varchar (8) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
    RecordStatus varchar (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
    ErrorDesc varchar (128) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    PrescriptionNo char(12) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    DrugName varchar(30)COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    NDC char(11) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
    create table #batches (
    BatchNo char(7) not null
    primary key (BatchNo))
    create table #custnos (
    CustNo char(4),
    ClientNo char(5), -- bcats associated with the customer
    primary key (CustNo, ClientNo)
    DECLARE
    @len_Argus_SubGroupId smallint,
    @len_Argus_PlanCode smallint,
    @len_vchParticipantId smallint,
    @len_vchProviderId smallint
    --Get field lengths for the following fields
    SELECT @len_Argus_SubGroupId = 4, --datalength([@tmpArgusWork].[Argus_SubGroupId]),
    @len_Argus_PlanCode = 8, --datalength(@tmpArgusWork.Argus_PlanCode),
    @len_vchParticipantId = 14, --datalength(@tmpArgusWork.vchParticipantId),
    @len_vchProviderId = 12 --datalength(@tmpArgusWork.vchProviderId)
    declare @maxbatch char(7)
    IF @BatchNo IS NULL
    begin
    -- assume normal run. Add ClientNo's and custno's to tables
    insert #custnos (CustNo, ClientNo)
    values ('0142', '1100')
    ,('0142', '1200')
    ,('0142', '1201')
    ,('0142', '1700')
    ,('0142', '1602')
    ,('0142', '1202')
    ,('0142', '1603')
    ,('0142', '2002')
    ,('0142', '1604')
    ,('0142', '2103')
    ,('0669', '*')
    -- get batches loaded since last batch loaded into PASOArgusClaims
    SELECT @maxbatch=Max(BatchNo)
    FROM ODSSupport.dbo.PASOArgusClaims
    declare @dt datetime
    declare @ds datetime
    select @dt = MIN(DateTimeStamp)
    from ODS.dbo.PharmacyClaim_Common
    where BatchNo <= @maxbatch
    and DateTimeStamp > DATEADD(dd,-16,getdate())
    insert #batches (BatchNo)
    select distinct BatchNo
    from ODS.dbo.PharmacyClaim_Common pcc
    inner join #custnos ct
    on ct.CustNo = pcc.ArgusCustNo
    and (
    ct.ClientNo = '*'
    or
    ct.ClientNo = pcc.ArgusClientNo
    where DateTimeStamp > @dt
    ; -- batch may have had a claim altered since last load, drop any batches already loaded into PASOArgusClaims
    with pba as (
    select distinct BatchNo
    from ODSSupport.dbo.PASOArgusClaims
    delete ba
    from #batches ba
    inner join pba
    on pba.BatchNo = ba.BatchNo
    end
    else if @NewBatchNo is not null and @CustNo is not null
    begin
    --make sure we haven't already done this batch number/customer combination
    set @maxbatch = @NewBatchNo
    SELECT @iCount=count(*)
    FROM PASOArgusClaims
    WHERE BatchNo=@maxbatch
    and Argus_BusinessCategory = @CustNo
    IF @iCount > 0
    begin
    PRINT 'Msg: Batch ' + @maxbatch + ' already exists for CustNo ' + @CustNo + '.'
    end
    else
    begin
    if @CustNo = '0142'
    begin
    insert #custnos (CustNo, ClientNo)
    values ('0142', '1100')
    ,('0142', '1200')
    ,('0142', '1201')
    ,('0142', '1700')
    ,('0142', '1602')
    ,('0142', '1202')
    ,('0142', '1603')
    ,('0142', '2002')
    ,('0142', '1604')
    ,('0142', '2103')
    end
    if @CustNo = '0669'
    begin
    insert #custnos (CustNo, ClientNo)
    values ('0669', '*')
    end
    insert #batches (BatchNo)
    values (@BatchNo)
    end
    end
    else
    begin
    --make sure we haven't already done this batch number
    set @maxbatch = @BatchNo
    SELECT @iCount=count(*)
    FROM PASOArgusClaims
    WHERE BatchNo=@maxbatch
    IF @iCount > 0
    begin
    PRINT 'Msg: Batch ' + @maxbatch + ' already loaded.'
    end
    else
    begin
    insert #batches (BatchNo)
    values (@maxbatch)
    end
    end
    ** Insert Pharmacy Claims to temporary table
    INSERT INTO #tmpArgusWork
    SELECT
    pharmClm.RxKey,
    isnull(@NewBatchNo, pharmClm.BatchNo),
    pharmclm.OrigDateTimeStamp as BatchDateTime,
    'PENDING' as BatchStatus,
    NULL as ReadyDateTime,
    substring(pharmClm.GrpNumber,1,8)as Argus_GroupID,
    left(pharmClm.ArgusSubgroup1,@len_Argus_SubGroupId) as Argus_SubgroupID,
    substring(pharmClm.GrpNumber,9,4) as Argus_ClassId,
    substring(pharmClm.GrpNumber,13,@len_Argus_PlanCode) as Argus_PlanCode,
    pharmClm.ArgusClientNo as Argus_BusinessCategory,
    '' as vchFacetsClaimSubtype,
    PASOClaimType = CASE WHEN pharmClm.ClaimType='A'
    THEN 'PHARMACY-ADJUST'
    ELSE 'PHARMACY'
    END,
    pharmClm.ClaimNo,
    pharmClm.DateCutoff as dtPaidDate,
    pharmClm.DateWritten as dtProcessDate,
    NULL as dtServiceDate,
    left(pharmClm.MemberId,@len_vchParticipantId) as vchParticipantId,
    left(pharmClm.PharmacyNo,@len_vchProviderId) as vchProviderId,
    vchProviderName = CASE WHEN pharmclm.PayMemberInd = 'Y'
    THEN 'Member Reimbursement'
    ELSE pharm.PharmName
    END,
    mClaimTotAmtCharge = CASE WHEN pharmclm.PayMemberInd = 'Y' -- When this is a member reimbursement use the amt paid
    THEN isnull(pharmClm.IngredientCostPaid,0) + isnull(pharmClm.DispenseFee,0) + isnull(APSFee,0) -- as amt charged.
    ELSE isnull(pharmClm.AmtBilled,0)
    END,
    case when pharmclm.PayMemberInd = 'Y'
    then isnull(pharmClm.AmtRejected,0) * -1
    else isnull(pharmClm.AmtBilled,0) - isnull(pharmClm.IngredientCostPaid,0) - isnull(pharmClm.DispenseFee,0) - isnull(APSFee,0) -isnull(pharmClm.AmtRejected,0)
    end as mClaimAmtDiscount,
    isnull(pharmClm.IngredientCostPaid,0) + isnull(pharmClm.DispenseFee,0) + isnull(APSFee,0) as mClaimAmtAllowed,
    isnull(pharmClm.AmtRejected,0) as mClaimAmtDenied,
    isnull(pharmClm.MemberPaidAmt,0) - isnull(pharmClm.MemberCopayAmt,0) as mClaimAmtDeduct,
    0 as mClaimAmtCoinsurance,
    isnull(pharmClm.MemberCopayAmt,0) as mClaimAmtCopay,
    isnull(pharmClm.AmtPaid,0) + isnull(APSFee,0) as mClaimAmtPaid,
    NULL as PASO_GroupID,
    NULL as PASO_SubgroupID,
    NULL as PASO_ClassID,
    NULL as PASO_PlanCode,
    NULL as PASO_BusinessCategory,
    'OK' as RecordStatus,
    NULL as ErrorDesc,
    PrescriptionNo = pharmClm.PrescriptionNo,
    DrugName = pharmClm.DrugName,
    NDC = pharmClm.NDC
    FROM ODS..PharmacyClaim as pharmClm
    LEFT JOIN ODS..pharmacy as pharm on
    pharmClm.PharmacyNo = pharm.PharmacyNo
    INNER join #batches ba
    on ba.BatchNo = pharmClm.BatchNo
    INNER join #custnos ct
    on ct.CustNo = pharmClm.ArgusCustNo
    and (
    ct.ClientNo = '*'
    or
    ct.ClientNo = pharmClm.ArgusClientNo
    WHERE pharmClm.ClaimType in ('P','A') -- Processed or Adjusted
    --AND pharmClm.ProcessCode <> 'MC' --code doesn't exist
    --GROUP BY
    -- pharmClm.BatchNo,
    -- substring(pharmClm.GrpNumber,1,8),
    -- substring(pharmClm.GrpNumber,9,4) ,
    -- substring(pharmClm.GrpNumber,13,@len_Argus_PlanCode),
    -- pharmClm.ArgusSubgroup1,
    -- pharmClm.ClaimNo,
    -- pharmClm.ArgusClientNo,
    -- pharmClm.DateCutoff,
    -- pharmClm.DateWritten,
    -- pharmClm.MemberId,
    -- pharmClm.PayMemberInd,
    -- pharmClm.PharmacyNo,
    -- pharm.PharmName,
    -- pharmClm.OrigDateTimeStamp,
    -- pharmClm.ClaimType,
    -- pharmClm.PrescriptionNo,
    -- pharmClm.DrugName,
    -- pharmClm.NDC
    IF @@RowCount=0
    BEGIN
    PRINT 'Msg: No records found.'
    RETURN
    END
    --Update the Discount column for these Pharmacy Claims
    --UPDATE @tmpArgusWork
    --SET mClaimAmtDiscount=mClaimTotAmtCharge-mClaimAmtAllowed-mClaimAmtDenied
    ** Get the lowest service Date for each claim and update temp table
    UPDATE #tmpArgusWork
    SET dtServiceDate = (SELECT min(pharmclm.DateSvc)
    FROM ODS..pharmacyClaim AS pharmclm
    WHERE pharmclm.ClaimNo = tcpr.vchClaimNumber
    AND pharmclm.MemberID = tcpr.vchParticipantId)
    FROM #tmpArgusWork as tcpr
    ** Copy over the eligibility fields that Argus provided
    UPDATE #tmpArgusWork
    SET PASO_GroupId = Argus_GroupID,
    PASO_SubGroupId = Argus_SubGroupId,
    PASO_ClassID=Argus_classid,
    PASO_PlanCode=Argus_PlanCode,
    PASO_BusinessCategory=Argus_BusinessCategory
    FROM #tmpArgusWork pw
    WHERE COALESCE(Argus_GroupID,'') <> ''
    OR COALESCE(Argus_SubGroupId,'') <> ''
    OR COALESCE(Argus_classid,'') <> ''
    OR COALESCE(Argus_PlanCode,'') <> ''
    OR COALESCE(Argus_BusinessCategory,'') <> ''
    ** If Argus did not provide all 5 eligibility fields, get them from faEnrollmentHistory
    ** based on the group, member, date of service
    UPDATE #tmpArgusWork
    SET PASO_GroupId = eh.GroupId,
    PASO_SubGroupId = eh.SubGroupId,
    PASO_ClassID=eh.Class,
    PASO_PlanCode=eh.PlanCode,
    PASO_BusinessCategory=eh.BusinessCategory
    FROM #tmpArgusWork pw
    INNER JOIN ODS..FAEnrollmentHistory eh
    ON eh.MemberID =pw.vchParticipantID
    AND eh.Groupid =pw.Argus_GroupID
    AND eh.eligind='Y'
    AND eh.ProcessCode<>'ID'
    AND pw.dtServiceDate BETWEEN eh.EligEffDate AND eh.EligTermDate
    WHERE COALESCE(Argus_GroupID,'') = ''
    OR COALESCE(Argus_SubGroupId,'') = ''
    OR COALESCE(Argus_classid,'') = ''
    OR COALESCE(Argus_PlanCode,'') = ''
    OR COALESCE(Argus_BusinessCategory,'') = ''
    ** If we have eligibility for all records, go ahead and set the ready date to today.
    IF NOT EXISTS ( SELECT *
    FROM #tmpArgusWork
    WHERE COALESCE(PASO_GroupID,'') = ''
    OR COALESCE(PASO_SubGroupID,'') = ''
    OR COALESCE(PASO_ClassID,'') = ''
    OR COALESCE(PASO_PlanCode,'') = ''
    OR COALESCE(PASO_BusinessCategory,'') = '')
    BEGIN
    UPDATE #tmpArgusWork
    SET ReadyDateTime=convert(varchar(10),GetDate(),101),
    BatchStatus='READY'
    END
    ELSE
    BEGIN
    PRINT 'Msg: Exceptions found.'
    UPDATE #tmpArgusWork
    SET RecordStatus='ERR',
    ErrorDesc='No valid Eligible span for this Member/Group/Subgroup at time of Service'
    WHERE COALESCE(PASO_GroupID,'') = ''
    OR COALESCE(PASO_SubGroupId,'') = ''
    OR COALESCE(PASO_ClassID,'') = ''
    OR COALESCE(PASO_PlanCode,'') = ''
    OR COALESCE(PASO_BusinessCategory,'') = ''
    END
    ** Insert the records into the final table.
    INSERT INTO PASOArgusClaims
    SELECT * FROM #tmpArgusWork
    SET NOCOUNT OFF
    END
    GO
    -- Verify that the stored procedure was created successfully.
    IF OBJECT_ID ('dbo.pr_Load_PASOArgusClaims_Work') IS NOT NULL
    PRINT '<<< CREATED PROCEDURE dbo.pr_Load_PASOArgusClaims_Work >>>'
    ELSE
    PRINT '<<< FAILED CREATING PROCEDURE dbo.pr_Load_PASOArgusClaims_Work >>>'
    GO
    GRANT EXECUTE ON dbo.pr_Load_PASOArgusClaims_Work to role_ODSLoad
    GO
    SET QUOTED_IDENTIFIER OFF
    GO
    SET ANSI_NULLS ON

    this part of the code below
    if@CustNo
    = '0142'
       begin
    insert #custnos(CustNo,
    ClientNo)
    values ('0142',
    '1100')
    ,('0142',
    '1200')
    ,('0142',
    '1201')
    ,('0142',
    '1700')
    ,('0142',
    '1602')
    ,('0142',
    '1202')
    ,('0142',
    '1603')
    ,('0142',
    '2002')
       end
    store proc
    How do I covert it to a common table where the values can be selected from when needed.

Maybe you are looking for

  • How do I set the default value in a PPD. (xerox accounting)

    I'm trying to modify a PPD for a xerox machine to set an accounting id into the default printing. I found the following in the PPD *XRFeature XRAccountingUserID: "string 0 20 Accounting" *XRFeature XRAccountingAccountID: "string 0 20 Accounting" *Ope

  • Creating a client out of a BPM WSDL

    Hi, Why do we get errors while creating a simple client out of BPM auto-generated WSDl's which work fine in SOAP UI? Whats the reason? The Process as a Web Service WSDL gives me an error while creating a client or even after creating a client , I get

  • Problem in business partner creation in GTS

    Hi experts,              To create business partner in GTS I have used BAPI_BUPA_CREATE_FROM_DATA. It is creating business partner but it is not updating the table u2018 /SALSLL/ADRCONu2019  which is necessary for SPL check in GTS. Is there any funct

  • How to install Glassfish V3.0.1 on Linux (especially Red Hat)

    I have to install an application server e.g. Glassfish V3.0.1 on Red Hat (Version number 4.1.2-48). Does anyone know how to install this appserver on a vm. I have downloaded this in my home directory but i am not sure where to install it and if i hav

  • HP PSC 1350 DRIVER MISSING ON WIRELESS/ THERE ON USB

    when i plug in my hp psc 1350 through my usb the drive is auto-selected with the HP All-in-One 2.7.2 but when i connect it through APE it's asking me to select the driver. the hp all-in-one 2.7.2 driver is not in the HP list....but its on my system s