Insert Logo into Query

Hi All,
I have searched the SDN forum and seen only a few posts for inserting a logo into a query, but still not 100% sure.
Basically, how to insert a logo into a query that will be there everytime the query is ran?  Not a workbook, but a query.  Also, how to get it into a specific cell?
Cheers,  Mike

Yes, everyone runs queries.
I put the select from list option and I can see the "workbook" that has formatting.  Meaning...
1. I ran a query and inserted logo, formatted font
2. Saved as a workbook
3. In Analyzer I selected Settings -> New Workbook on Embed
4. Now open query
5. I get the popup to select my query...I select it
6. I now get an option to select the workbook to embed my query in...I select it and all the formatting and logo is there.
So...
Is this how it works?  If so, When selecting the workbook to embed my query in it still has all the data/result from last query run.  Is there anyway not to have this "old" data show up?  In other words, is there a way to create several default workbooks (to embed different queries in from different divisions), so when different divisions run different queries, they can select their "formatting workbook".
Example:
Shoes would have their "Shoe Workbook"
Pants would have their "Pant Workbook"
Thanks,
Mike

Similar Messages

  • Inserting logo into smartform

    Hi,
    How to insert a logo into smart form
    Thanks,
    Malini.

    SE78 Upload Logo
    Printing Graphics
    Use
    You use the graphic node to display graphics, such as a company logo, on the form. For performance reasons, make sure that the graphics are held in the printer memory. SAP Smart Forms support this method, provided that:
    •     The printer can be controlled accordingly.
    •     There is enough memory space on the printer.
    •     You activated this property in transaction SE78 (see below).
    In this case, the system sends the graphics to the printer only once during one print job.
    To include background graphics, use the Background graphic tab of a page node.
    Prerequisites
    You use the SAPscript Graphic Administration (transaction SE78) to import graphics into the SAP-System:
    1.     Double-click on a graphic format in the tree structure in the forder Document server  GRAPHICS General graphics.
    2.     Choose Graphic  import.
    The transaction imports the graphic and stores it on the Business Document Server (BDS). Now you can display it on a form.
    See also: Graphic Administration [Page 56]
    Procedure
    1.     To create a graphic node, call the context menu for that node in the tree structure that you want to contain the graphic and choose Create  Graphic.
    Create the graphic node as direct successor of the page node or use the context menu in the layout of the Form Painter. You can then position the graphic anywhere on the page.
    In the Form Painter the system displays a small box for the newly created node.
    2.     Enter a unique name for the node and a description (for example, company logo).
    3.     On the General Attributes tab determine whether you want to include a colored graphic or a graphic in black and white.
    4.     Use the fields Object, ID, and Name to identify the graphic. Use F4 help of the Name field to copy the values of these fields. If you copy them with ENTER, the system displays the graphic in the Form Painter.
    The box for the graphic in the Form Painter also contains the name of the graphic node, which in part overlays the graphic.
    5.     In the Technical Attributes box determine the graphic resolution according to what the printer supprts. Small resolutions increase the size of the graphic on the form, higher resolutions reduce the size.
    6.     For graphic nodes that are displayed in a window, there is a box Horizontal position in addition to the general output options [Page 21]. The parameters Reference point and Alignment determine the horizontal position in the window, while the vertical position is determined by the previous output in the window.
    At present, you cannot overlay graphics with text. However, if you use a template node [Page 29], you can display graphics and text side by side.
    Result
    The system displays the node with name and description in the tree structure. If you insert a graphic as direct successor of a page or if you used the Form Painter, the system displays the graphic. Graphics in windows are inserted only when the form is processed. You can therefore not see them in the Form Builder. In addition, the system automatically dispalys the graphic on the next page if there is not enough space left on the current page.

  • Inserting logo into ALV TOP-OF-PAGE

    Hello friends,
                         I would like to insert a self made logo into top-of-page of ALV reports.I know the function module that is REUSE_ALV_COMMENTARY_WRITE but how to specify the link used where the image has been stored.
      Regards
      Ashish.

    Hi,
    goto se78 tcode.
    GRAPHICS->BMAP double click on bmap.
    press import button in application tool bar.
    one window will come. give the image path,some name(say ABC),description of the logo and press enter
    <b>in program</b>
    REPORT ZBHALV_LIST1.
    TABLES:MARA.
    SELECT-OPTIONS: MATNR FOR MARA-MATNR.
    DATA:BEGIN OF ITAB OCCURS 0,
         MATNR LIKE MARA-MATNR,
         ERSDA LIKE MARA-ERSDA,
         MTART LIKE MARA-MTART,
         MBRSH LIKE MARA-MBRSH,
    END OF ITAB.
    SELECT * FROM MARA INTO CORRESPONDING FIELDS OF TABLE ITAB WHERE MATNR
    IN MATNR.
    TYPE-POOLS SLIS.
    DATA:FCAT TYPE slis_t_fieldcat_alv.
    DATA:LAYOUT TYPE slis_layout_alv.
    <b>DATA:EVE TYPE slis_t_event WITH HEADER LINE.</b>
    DATA:HEAD TYPE slis_t_listheader WITH HEADER LINE.
    DATA:SORT TYPE slis_t_sortinfo_alv WITH HEADER LINE.
    SORT-UP = 'X'.
    SORT-SPOS = 1.
    SORT-FIELDNAME = 'ERSDA'.
    SORT-tabname = 'MARA'.
    APPEND SORT.
    SORT-SPOS = 2.
    SORT-FIELDNAME = 'MTART'.
    SORT-tabname = 'MARA'.
    APPEND SORT.
    <b>EVE-NAME = 'TOP_OF_PAGE'.
    EVE-FORM = 'TOPOFPAGE'.
    APPEND EVE.</b>
    EVE-NAME = 'TOP_OF_LIST'.
    EVE-FORM = 'TOPOFLIST'.
    APPEND EVE.
    EVE-NAME = 'END_OF_LIST'.
    EVE-FORM = 'ENDOFLIST'.
    APPEND EVE.
    LAYOUT-ZEBRA = 'X'.
    LAYOUT-no_hline = 'X'.
    LAYOUT-NO_VLINE = 'X'.
    LAYOUT-window_titlebar = 'MATERIAL DETAILS'.
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
       I_PROGRAM_NAME               = SY-REPID
       I_INTERNAL_TABNAME           = 'ITAB'
       I_INCLNAME                   = SY-REPID
      CHANGING
        CT_FIELDCAT                  = FCAT.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
       I_CALLBACK_PROGRAM             = SY-REPID
       IS_LAYOUT                      = LAYOUT
       IT_FIELDCAT                    = FCAT
       IT_SORT                        = SORT[]
       IT_EVENTS                      = <b>EVE[]</b>
      TABLES
        T_OUTTAB                       = ITAB.
    <b>FORM TOPOFPAGE.
    REFRESH HEAD.
        HEAD-TYP = 'H'.
        HEAD-INFO = 'MATERIALS'.
        APPEND HEAD.
        CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
          EXPORTING
            IT_LIST_COMMENTARY       = HEAD[]
            I_LOGO                   = 'ABCD'
          I_END_OF_LIST_GRID       =
    ENDFORM.</b>
    FORM TOPOFLIST.
    REFRESH HEAD.
        HEAD-TYP = 'H'.
        HEAD-INFO = 'MATERIALS-LISTTOP'.
        APPEND HEAD.
        CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
          EXPORTING
            IT_LIST_COMMENTARY       = HEAD[]
          I_LOGO                   =
          I_END_OF_LIST_GRID       =
    ENDFORM.
    FORM ENDOFLIST.
    REFRESH HEAD.
        HEAD-TYP = 'H'.
        HEAD-INFO = 'MATERIALS-LISTEND'.
        APPEND HEAD.
        CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
          EXPORTING
            IT_LIST_COMMENTARY       = HEAD[]
          I_LOGO                   =
          I_END_OF_LIST_GRID       =
    ENDFORM.
    rgds,
    bharat.

  • Inserting Logos into Signatures

    Hi, I'm a newbie to Mac (less than 5 days old) .... looking for a little help.
    I've managed to create an email signature and dragged my company logo from my stick into the window but I can't resize it.
    Is there someway I can do this easily???

    I am in the same boat as you more or less. With windows I had the whole address and Jpeg which I could use at the end of a letter. I can import the old text from windows OK., but, as you have found, the image is well overdimensioned & needs resizing.
    If you get a sensible reply to your question kindly forward it.
    My new Mac is super for photos, but otherwise can be well exasperating!
    I would recommend you buy 'Switching to the Mac' & also 'i-photo 09' by David Pogue. These helped me, but I couldn't hack it all.
    Let me know how you get on.
    Regds., John Clifford in Switzerland, but a Londoner!

  • Insert logo in alv

    hello experts....
    In alv reports how i insert logo into alv grid ?tell me procedure, in the same report how insert background logo?

    Hi,
    At first you have to upload the logo in the application server using transaction 'OAER'.
       1. Go to Transaction OAER,
       2. Give Class Name as PICTURES
       3. Class type as OT
       4. Object Key as the name of the Object u want to specify
       5. Upon execution you would be prompted to give the file path details. Just upload which ever logo u want to display
       6. Now you can use the same name in your ALV FM
    In your ALV program, you need to have event for TOP_OF_PAGE, and also this works only in case of Grid not in ALV LIST.
    Look at the sample code to display LOGO.
    call function 'REUSE_ALV_GRID_DISPLAY'
    exporting
      i_callback_program = i_repid
      it_fieldcat = header
      is_layout = gt_layout
      i_callback_top_of_page = 'TOP-OF-PAGE1'
      i_grid_title = xyz
      it_sort = gt_sort[]
      i_default = 'X'
      i_save = 'U'
      is_variant = gt_variant
      it_events = gt_events
    tables
      t_outtab = t_output.
    Form TOP-OF-PAGE1
    form top-of-page1.
    data: header type slis_t_listheader,
          wa     type slis_listheader.
    TITLE AREA
    wa-typ = 'S'.
    wa-info = text-h04.
    append wa to header.
    wa-typ = 'S'.
    write sy-datum to wa-info mm/dd/yyyy.
    concatenate text-h03 wa-info into wa-info separated by space.
    append wa to header.
    wa-typ = 'S'.
    concatenate text-h02 sy-uname into wa-info separated by space.
    append wa to header.
    wa-typ = 'S'.
    concatenate text-h01 sy-repid into wa-info separated by space.
    append wa to header.
    ********" LOGO
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = header
    i_logo = 'ENJOYSAP_LOGO'.
    *********" LOGO
    endform.
    Here in TOP-OF-PAGE form it will show you the Prog name,Date, User Name.

  • How to insert the image or logo into the table as a field in webdynpro abap

    Hi Friends,
    Please tell me how to insert the image or logo into the table as a field in webdynpro abap.........

    Hi Alagappan ,
          In your view layout you take table UI element and then you bind it with some context nodes.
    The attributes of your nodes comes as a field.
    Now in these fields you can set various properties and image is one of them.
    Go to ->
    1. View Layout -> Right Click on ROOTUIELEMENTCONTAINER -> INSERT ELEMENT -> TABLE
    2. Right click on table -> Create Binding.
       Here you have to bind it with the appropriate context node.
    You will get two properties here
    a- Standard Cell Editor :- ( make it image )
    b- Standard properties :- ( If required set image properties ).
    3. If you want put image from out side then import it as a mime object and set the source of your table field ( used as a image )
    also have a look :-
    [Image Properties|http://help.sap.com/saphelp_nw04/helpdata/en/f3/1a61a9dc7f2e4199458e964e76b4ba/content.htm]
    Hope this will solve your problem.
    Reply if any case of any issue.
    Thanks & Regards,
    Monishankar C

  • SELECT * cannot be used in an INSERT INTO query when the source or destination table contains a multivalued field

    Hi,
    I am using Access 2013 and I have the following VBA code, 
    strSQL = "INSERT INTO Master SELECT * from Master WHERE ID = 1"
     DoCmd.RunSQL (strSQL)
    when the SQL statement is run, I got this error.
    SELECT * cannot be used in an INSERT INTO query when the source or destination table contains a multivalued field
    Any suggestion on how to get around this?
    Please advice and your help would be greatly appreciated!

    Rather than modelling the many-to-many relationship type by means of a multi-valued field, do so by the conventional means of modelling the relationship type by a table which resolves it into two one-to-many relationship types.  You give no indication
    of what is being modelled here, so let's assume a generic model where there is a many-to-many relationship type between Masters and Slaves, for which you'd have the following tables:
    Masters
    ....MasterID  (PK)
    ....Master
    Slaves
    ....SlaveID  (PK)
    ....Slave
    and to model the relationship type:
    SlaveMastership
    ....SlaveID  (FK)
    ....MasterID  (FK)
    The primary key of the last is a composite one of the two foreign keys SlaveID and MasterID.
    You appear to be trying to insert duplicates of a subset of rows from the same table.  With the above structure, to do this you would firstly have to insert rows into the referenced table Masters for all columns bar the key, which, presuming this to be
    an autonumber column, would be assigned new values automatically.  To map these new rows to the same rows in Slaves as the original subset you would then need to insert rows into SlaveMastership with the same SlaveID values as those in Slaves referenced
    by those rows in Slavemastership which referenced the keys of the original subset of rows from Masters, and the MasterID values of the rows inserted in the first insert operation.  This would require joins to be made between the original and the new subsets
    of rows in two instances of Masters on other columns which constitute a candidate key of Masters, so that the rows from SlaveMastership can be identified.
    You'll find examples of these sort of insert operations in DecomposerDemo.zip in my public databases folder at:
    https://onedrive.live.com/?cid=44CC60D7FEA42912&id=44CC60D7FEA42912!169
    If you have difficulty opening the link copy its text (NB, not the link location) and paste it into your browser's address bar.
    In this little demo file non-normalized data from Excel is decomposed into a set of normalized tables.  Unlike your situation this does not involve duplication of rows into the same table, but the methodology for the insertion of rows into a table which
    models a many-to-many relationship type is broadly the same.
    The fact that you have this requirement to duplicate a subset of rows into the same table, however, does make me wonder about the validity of the underlying logical model.  I think it would help us if you could describe in detail just what in real world
    terms is being modelled by this table, and the purpose of the insert operation which you are attempting.
    Ken Sheridan, Stafford, England

  • How to insert date into ms access database using sql query in servlet

    sir all thing is working well now only tell me how we can insert date into ms access database which is input by user .
    insert into db2(bookname,studentname,date) values('"+bname+"','"+sname+"',date_format)";{code}
    or either the system date is inserted with query .
      plz help me
    thanx                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    bhavishya wrote:
    sir all thing is working well now only tell me how we can insert date into ms access database which is input by user .
    insert into db2(bookname,studentname,date) values('"+bname+"','"+sname+"',date_format)";{code}
    or either the system date is inserted with query .
    plz help me
    thanxAnd that SQL statement is another reason to use PreparedStatement. I assume bname and sname are input from some form? Well, if that's the case, simply inserting them into SQL by simple String concatenation is just begging for all sorts of problems. What if there is an apostrophe in the entry? Broken Statement. Worse, it's a wide open invitation to an SQL Injection attack.

  • Insert or copy query into workbook 7.0

    How Can I copy a query into a workbook with new Analyzer 7.0 ?
    In the old version (Analyzer 3.x), I can choose Tools->Insert (or copy) query.
    How Can I do the same with Analyzer 7.0 ?
    Thanks

    Hi,
    .) Open the analyser and connect to the BI system,
    .) open an empty excel
    .) switch to design mode (first icon on second task menu)
    .) insert a table (second icon on second task menu)
    .) select the query
    and so on...
    BR
    /C

  • INSERT INTO QUERY AGAINST ORACLE

    I've tested the INSERTINTO query where it successfully pulls data from one table in SQL DB and inserts into another SQL DB.
    However, when I use the same script to pull data from one table in Oracle DB to another table in Oracle DB, I get an error.
    I'm assuming the syntax is a little different for Oracle?
    Added debugging and the query looks like this...
    ** Begin FDM Runtime Error Log Entry [2012-06-27-21:20:57] **
    ERROR:
    Code............................................. 1
    Description...................................... INSERT INTO tWadmin30284128092 (PartitionKey, CatKey, PeriodKey, DataView, CalcAcctType, Entity, Account, UD1, UD2, UD4, Amount) SELECT 752, 12, '31-Mar-2008', 'YTD', 9, Entity, Account, UD1, UD2, UD4, Amount FROM tdataseg4
    Error Message...
    ** Begin FDM Runtime Error Log Entry [2012-06-27-21:10:52] **
    ERROR:
    Code............................................. -2147217900
    Description...................................... ORA-02291: integrity constraint (FDM1113ORCL.FKC_DS6_TCTRLPERIOD) violated - parent key not found
    INSERT /*+ Append */ INTO tDataSeg6 ( PartitionKey, CatKey, PeriodKey, DataView, CurKey, CalcAcctType, ChangeSign, JournalID, Amount, AmountX, Account, AccountX, AccountR, AccountF, Entity, EntityX, EntityR, EntityF, ICP, ICPX, ICPR, ICPF, UD1, UD1X, UD1R, UD1F, UD2, UD2X, UD2R, UD2F, UD3, UD3X, UD3R, UD3F, UD4, UD4X, UD4R, UD4F, DESC1, DESC2, ATTR1, ATTR2, ATTR3, ATTR4, ATTR5, ATTR6, ATTR7, ATTR8, ATTR9, ATTR10, ATTR11, ATTR12, ATTR13, ATTR14, ArchiveID, HasMemoItem, StaticDataKey ) SELECT PartitionKey, CatKey, PeriodKey, DataView, CurKey, CalcAcctType, ChangeSign, JournalID, Amount, AmountX, Account, AccountX, AccountR, AccountF, Entity, EntityX, EntityR, EntityF, ICP, ICPX, ICPR, ICPF, UD1, UD1X, UD1R, UD1F, UD2, UD2X, UD2R, UD2F, UD3, UD3X, UD3R, UD3F, UD4, UD4X, UD4R, UD4F, DESC1, DESC2, ATTR1, ATTR2, ATTR3, ATTR4, ATTR5, ATTR6, ATTR7, ATTR8, ATTR9, ATTR10, ATTR11, ATTR12, ATTR13, ATTR14, ArchiveID, HasMemoItem, StaticDataKey From tWadmin436038889587
    Procedure........................................ clsDataManipulation.fExecuteDML
    Component........................................ upsWDataWindowDM
    Version.......................................... 1111
    Thread........................................... 3888
    Function INSERTINTO(strLoc, lngCatKey, dblPerKey, strWorkTableName)
    'Oracle Hyperion FDM IMPORT Integration Script:
    'Created By:       admin
    'Date Created:       2012-06-27-21:01:10
    'Purpose:
    Dim objSS 'ADODB.Connection
    Dim strSQL 'SQL String
    Dim rs 'Recordset
    Dim rsAppend 'tTB table append rs Object
    Dim strPeriod
    Dim strYear
    'Period
    'strPeriod=MonthName(Month(RES.PdtePerKey))
    a=CStr(FormatDateTime(RES.PdtePerKey,1))
    'Tuesday,January 30, 2012
    b=Right(a,(Len(a)-Len(DW.Utilities.fParseString(a,1,1,",")))) '7
    c=DW.Utilities.fParseString(b,2,2,",")
    strPeriod=Left(c,3)
    'Year
    'strYear=Year(RES.PdtePerKey)
    strYear=Right(b,4)
    DW.DBTools.mLogError 1, CStr(strPeriod), CStr(strYear), Nothing
    'Initialize objects
    Set cnSS = CreateObject("ADODB.Connection")
    'Connect To SQL Server database
    cnss.open "Provider=OraOLEDB.Oracle.1;Password=password;Persist Security Info=True;User ID=fdm1113orcl;Data Source=orcl"
    'DW.DBTools.mLogError 1, CStr(strSQL), CStr(strSQL), Nothing
    'Initialize common SQL statement
    strSQL = "INSERT INTO " & _
            strWorkTableName & " " & _
            "(PartitionKey, CatKey, PeriodKey, DataView, CalcAcctType, Entity, Account, UD1, UD2, UD4, Amount) " & _
            "SELECT  " & RES.PlngLocKey & ", " & RES.PlngCatKey & ", " & _
            "'" & Day(RES.PdtePerKey) & "-" & MonthName(Month(RES.PdtePerKey), True) & "-" & Year(RES.PdtePerKey) & "', " & _
            "'YTD', 9, Entity, Account, UD1, UD2, UD4, Amount " & _
            "FROM tdataseg4 " '& _
    DW.DBTools.mLogError 1, CStr(strSQL), CStr(strWorkTableName), Nothing
    DW.DataManipulation.fExecuteDML(strSQL)
    'cnss.Execute strSQL
    'Records loaded
    RES.PlngActionType = 6
    RES.PstrActionValue = "SQL Import successful!"
    'Assign Return value
    INSERTINTO = True
    cnss.Close
    Set cnss = Nothing
    End FunctionEdited by: user12152138 on Jun 27, 2012 6:29 PM
    Edited by: user12152138 on Jun 27, 2012 6:33 PM
    Edited by: user12152138 on Jun 27, 2012 6:36 PM
    Edited by: user12152138 on Jun 27, 2012 6:37 PM
    Edited by: user12152138 on Jun 27, 2012 6:46 PM

    Hi together,
    I fixed the problem. I multiply the origin number with 10. The result is a number without any comma. During the insert into MSSql I divide by 10.
    I now, this is a very strange solution but it works.
    Yes I know this helps only, because the column can only save number with one decimal place. For higher decimal places you have to multiple it with 100 or 1000 or......
    Hope this helps also other peoples.
    kind regards
    Joe

  • Insert result of query into a table with unique constraint

    Hi,
    I have a query result that I would like to store in a table. The target table has a unique constraint. In MySQL you can do
    insert IGNORE into myResultTable <...select statement...>
    The IGNORE clause means if inserting a row would violate a unique or primary key constraint, do not insert the row, but continue inserting the rest of the query. Leaving the IGNORE clause out would cause the insert to fail and an error to return.
    I would like to do this in oracle... that is insert the results of a query that are not already in the target table. What is the best way to do this? One way is use a procedural language and loop through the first query, checking to see if each row is a duplicate before inserting it. I would think this would be slow if there are lots of records. Other options...
    insert into myTargetTable
    select value from mySourceTable where ... and not exists (select 'x' from myTargetTable where value = mySourceTable.value)
    insert into myTargetTable
    select mySourceTable.value
    from myTargetTable RIGHT JOIN mySourceTable
    ON myTargetTable.value = mySourceTable.value
    where ...
    and myTargetTable.value IS NULL
    any other suggestions?
    Thanks,
    Simon

    Try doing a MINUS instead of not exists., ie Source MINUS Target.
    Disabling the constraint will not help you since this will allow the duplicate rows to be inserted into the table. I don't think you want this.
    --kalpana                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Having trouble inserting a logo into my video

    I am having difficulty inserting a logo into my video. Whenever, I am successful, and I go to play the video, the logo moves out of place. I deleted all of the effects but am still having trouble with it.

    We have no idea what the problem is or how you applied the logo from that brief description!

  • Insert cc license logo into metadata in Aperture 3.2.4

    Hi,
    I'm trying to find out if I can insert a creative commons license like this: into the usage terms part of the IPTC metadata into selected photos AFTER import. I am working on a huge batch of photos by different photographers (many photos found on flickr), to be used on a website. The cc logos are available in svg, eps, png or giff.
    file:///Users/worldreligions/Dropbox/panorama%202013/Downloads%20-%20Creative%20 Commons.html
    We are aiming for the metadata to be viewable alongside the photo or when people click onto details. I cannot see how to insert this into the 'Usage', where I think it should go.
    Thank you for your ideas.
    Helen

    There is no provision as far as I  am aware to put an image into any of the IPTC fields, they are text only. (I'm pretty sure this is not an Aperture limitation but applies to IPTC fields in general)

  • Query for inserting data into table and incrementing the PK.. pls help

    I have one table dd_prohibited_country. prohibit_country_key is the primary key column.
    I have to insert data into dd_prohibited_country based on records already present.
    The scenario I should follow is:
    For Level_id 'EA' and prohibited_level_id 'EA' I should retreive the
    max(prohibit_country_key) and starting from the maximum number again I have to insert them
    into dd_prohibited_country. While inserting I have to increment the prohibit_country_key and
    shall replace the values of level_id and prohibited_level_id.
    (If 'EA' occurs, I have to replace with 'EUR')
    For Instance,
    If there are 15 records in dd_prohibited_country with Level_id 'EA' and prohibited_level_id 'EA', then
    I have to insert these 15 records starting with prohibit_country_key 16 (Afetr 15 I should start inserting with number 16)
    I have written the following query for this:
    insert into dd_prohibited_country
    select     
         a.pkey,
         b.levelid,
         b.ieflag,
         b.plevelid
    from
         (select
              max(prohibit_country_key) pkey
         from
              dd_prohibited_country) a,
         (select
    prohibit_country_key pkey,
              replace(level_id,'EA','EUR') levelid,
              level_id_flg as ieflag,
              replace(prohibited_level_id,'EA','EUR') plevelid
         from
              dd_prohibited_country
         where
              level_id = 'EA' or prohibited_level_id = 'EA') b
    My problem here is, I am always getting a.pkey as 15, because I am not incrementing it.
    I tried incrementing it also, but I am unable to acheive it.
    Can anyone please hepl me in writing this query.
    Thanks in advance
    Regards
    Raghu

    Because you are not incrementing your pkey. Try like this.
    insert
       into dd_prohibited_country
    select a.pkey+b.pkey,
         b.levelid,
         b.ieflag,
         b.plevelid
       from (select     max(prohibit_country_key) pkey
            from dd_prohibited_country) a,
         (select     row_number() over (order by prohibit_country_key)  pkey,
              replace(level_id,'EA','EUR') levelid,
              level_id_flg as ieflag,
              replace(prohibited_level_id,'EA','EUR') plevelid
            from     dd_prohibited_country
           where level_id = 'EA' or prohibited_level_id = 'EA') bNote: If you are in multiple user environment you can get into trouble for incrementing your PKey like this.

  • How to insert the select query result into table?

    How to insert the select query result into table?
    SELECT  top 20 creation_time  
            ,last_execution_time 
            ,total_physical_reads
            ,total_logical_reads  
            ,total_logical_writes
            , execution_count 
            , total_worker_time
            , total_elapsed_time 
            , total_elapsed_time / execution_count avg_elapsed_time
            ,SUBSTRING(st.text, (qs.statement_start_offset/2) + 1,
             ((CASE statement_end_offset 
              WHEN -1 THEN DATALENGTH(st.text)
              ELSE qs.statement_end_offset END 
                - qs.statement_start_offset)/2) + 1) AS statement_text
    FROM sys.dm_exec_query_stats AS qs
    CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) st
    ORDER BY total_elapsed_time / execution_count DESC;
    Thanks,
    Tirumala

    1. SELECT INTO
    Below method will create table when data is inserted from one table to another table. Its useful when you need exactly same datatype as source table.
    Use AdventureWorks2008R2;
    Go
    ---Insert data using SELECT INTO
    SELECT AddressLine1, City
    INTO BothellAddresses
    FROM Person.Address
    where City = 'Bothell';
    GO
    ---VERIFY DATA
    Select AddressLine1, City
    FROM BothellAddresses
    ---DROP TABLE
    DROP TABLE BothellAddresses
    GO
    2. INSERT INTO SELECT
    Below method will need table to be created prior to inserting data. Its really useful when table is already created and you want insert data from
    another table.
    Use AdventureWorks2008R2;
    Go
    ---Create Table
    CREATE TABLE BothellAddresses (AddressLine1 NVARCHAR(60), City NVARCHAR(30))
    ---Insert into above table using SELECT
    INSERT INTO BothellAddresses(AddressLine1, City)
    SELECT AddressLine1, City
    FROM Person.Address
    where City = 'Bothell';
    ---VERIFY DATA
    Select AddressLine1, City
    FROM BothellAddresses
    ---DROP TABLE
    DROP TABLE BothellAddresses
    GO
    Regards,
    Vishal Patel
    Blog: http://vspatel.co.uk
    Site: http://lehrity.com

Maybe you are looking for