How to add spaces to the column value to make it up specifi length string please

Hello There,
Could you please guide me here to solve this issue,
in my column (named as State) contains values as below
California
Washington
Utah
Connecticut
Massachusets
in the output how can i add a spaces to make up every column values as 15 length (for ex, Utah is 4 length then need to add 11 spaces, California is 10 would like to add 5 spaces)
i tried below but no use in Sql 2008 R2
SELECT  distinct state
   state
+SPACE(35-len(state)),
len(state+SPACE(35-len(state)))
FROM dbo.ordersInfo
Thank you in advance
Milan

Fixed length CHAR(n) data in SQL is automatically padded with spaces. Either change the column's data type or cast to it. Also, the ISO-11179 rules are that the column should be "state_name" and not just the root attribute "state" -- state_code, state_population,
etc are a few of the confusions you created. 
Another rule of RDBMS is that we do not do display formatting in the data. That is what presentation layers do. Why are you trying to fake COBOL in SQL? 
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL

Similar Messages

  • How to add spaces at the end of record

    Hi Friends,
    i am creating a file which contains more than 100 records.
    In ABAP i have internal table with on field(135) type c.
    some time record have length 120, somtime 130 its vary on each record.
    but i would like to add space at the end of each record till 135 length.
    Can you please help me how to add speace at the end of record.
    regards
    Malik

    So why did you said that in your first posting? My glass sphere is out for cleaning...
    Instead of type c use strings and add spaces until they have the appropriate length.
    loop at outtab assigning <pout>.
      while strlen( <pout>-val ) < 135.
        concatenate <pout>-val `` into <pout>-val.
      endwhile.
    endloop.

  • How to add -Select- as the first value in dropdownbox?

    Hi All,
    I am having a dropdownbox with the set of values. I need to add -SELECT- as the first and default value. Please do advise how to achieve this.
    Code and screenshot below.
    var oModel = new sap.ui.model.odata.ODataModel("../../services/admin/typesTable.xsodata/", false);
    var oSort = new sap.ui.model.Sorter("ID", false);
    var lblType = new sap.ui.commons.Label();
    lblType.setText("Type");
    var ddbType = new sap.ui.commons.DropdownBox();
    ddbType.setRequired(true);
    var oItemTemplate = new sap.ui.core.ListItem();
    oItemTemplate.bindProperty("text", "NAME");
    oItemTemplate.bindProperty("key", "ID");
    ddbType.setModel(oModel);
    ddbType.bindItems("/TYPES", oItemTemplate, oSort);
    lblType.setLabelFor(ddbType);
    oChildLayout.createRow(lblType, ddbType);
    Thanks in advance
    Aravindh

    Hi,
    Refer this discussion on exact requirement empty/"all" entry in DropdownBox with OData model - cleanest solution
    Regards,
    Chandra

  • How to allow space in the column names

    Hi
    My program reads data from an excel file which has columns named "Fiscal Year" and "current period". I can read data from the file as below...
    select * from the_file
    But it does not allow me, if I write the following sql statement.
    select distinct fiscal Year, current period from the_file
    I need to get distinct values from these two columns and the order in which these columns will appear in excel file is not fixed.
    I tried
    select distinct 'fiscal Year', 'current period' from the_file
    But it did not work
    Please help as how can I specify these columns that has a space in its name.
    Thanks

    Have you tried Double quotes as in:
    select distinct "fiscal Year", "current period" from the_file;

  • URGENT : How to add spaces in the outbound file

    Hi Gurus,
    I am writing data from SAP to a Unix file via an ABAP program.
    The file has one record with 4000 characters with 2000 spaces in between the datas.
    Is there any command to add these spaces ? Or I have to go through a loop to add them ? I cannot leave them and assume that they will be spaces by default,as this is causing some error in Unix side.
    Please help,this is urgent.
    Regards,
    Sandip.

    heyy i could find the solution to it....so am closing the thread..thanksss

  • How to not repeat the column values if repeated on next line and so on..?

    Hi all,
    The XmlP template that is designed gives me the output as follows :
    COL1 COL2 COL3 COL4 COL5 COL6 COL7
    abc 1 1000.00 10.00 95.00 695.00 cad
    abc 2 1000.00 100.00 95.00 695.00 cad
    abc 3 1000.00 100.00 95.00 695.00 cad
    But my requirement is as follows :
    COL1 COL2 COL3 COL4 COL5 COL6 COL7
    abc 1 1000.00 10.00 95.00 795.00 cad
    - 2 - 100.00 - - -
    - 3 - 100.00 - - -
    Note : "-" indicates blank column values (gaps are being filled)
    How do I not repeat the column values if repeated?
    Please let me know if you have answer for it?
    Thanks in Advance
    Munna

    Iam trying to design the xml publisher template using xmlp template builder.
    My requirement is :
    For a receipt number, I have receipt amount, applied amount, unapplied amount and on account amount. And for each receipt, there can be multiple applied amount ( as the receipt can be applied multiple times), but the unapplied amount, on account amount and receipt amount is single.
    By using the logic as said above from http://blogs.oracle.com/xmlpublisher/2007/04/13
    Iam getting the output something like this:
    Receipt Number| Receipt Amount | App Amount |UnappAmount|OnaccountAmount|
    111-b|249.28|249.28|0.00|0.00|
    1110|1,000.00|10.00|95.00|795.00|
    1110| -|10.00|-|-|
    1112|1500.00|1,271.02|-|-|
    1112|-|228.98|-|-|
    My requirement is to go get something like this:
    Receipt Number| Receipt Amount | App Amount |UnappAmount|OnaccountAmount|
    111-b|249.28|249.28|0.00|0.00|
    1110|1,000.00|10.00|95.00|795.00|
    1110| -|10.00|-|-|
    1112|1500.00|1,271.02|0.00|0.00| ---> here lies the difference
    1112|-|228.98|-|-|
    How do i check the duplicate of the column values only for a receipt number??
    Because as for receipt no. 111-b the unapplied amount and on account amount is 0.00, the the unapplied amount and on account amount for receipt number 1112 is getting hided( because its a duplicate) . In reality, it should be 0.00 and any other line for that receipt number (1112) should be hided. except for the applied amount.
    Note We can see that last 2 columns in the last record( for receipt number 1112) is getting hided that is as expected but for 4th record the unapplied amount and on account amount should be 0.00 respecively.
    '-' indicates hided value
    Please help.
    Thanks in Advance

  • How to get the column values from a BC4J View Table in UIXML?

    I am using a default UiXML Application for Order Entry system with Orders & Order Lines & Customers. I have a uix file OrdersView1_View.uix which displays (no updateable columns) all the Orders. How do I get the column value of a selected row in a BC4J Table (example:OrdersId) when a Submit button is pressed using UIXML or Java Classes?
    I appreciate any help on this.

    Hi,
    You need to use keyStamp, an example:
    <bc4j table name="orders">
    <bc4j:keyStamp>
    <bc4j:rowKey name="key" />
    </bc4j:keyStamp>
    Furthermore, you can automatically send the selected row key using the go event handler, so in the handlers section you could send the key to an orderInfo page:
    <event name="show">
    <!-- forward to the update page, passing
    the selected key as a page property -->
    <ctrl:go name="orderInfo" redirect="true">
    <ctrl:property name="key">
    <ctrl:selection name="orders" key="key" />
    </ctrl:property>
    </ctrl:go>
    </event>

  • How to update zero to a column value when record does not exist in table but should display the column value when it exists in table?

    Hello Everyone,
    How to update zero to a column value when record does not exist in table  but should display the column value when it exists in table
    Regards
    Regards Gautam S

    As per my understanding...
    You Would like to see this 
    Code:
    SELECT COALESCE(Salary,0) from Employee;
    Regards
    Shivaprasad S
    Please mark as answer if helpful
    Shiv

  • How to get the column values

    hi
    i am new to programming... i would like to know how to get the column values... i have a resultset object
    i need code .... asap
    thnx

    @OP: It is always good to type complete sentences and describe your problem at length. It helps in letting people know what you really need instead of making wild guesses or silly jokes. You post mentions that you get the ResultSet. Then you should look up the API docs for java.sql.ResultSet and take a look at the getxxx() method signatures. Use the ones which suit the specific case.
    Besides, it is good to refrain from using asap and urgent. Even if something is urgent to you, it need not be urgent to others. Wording a question properly would attract better replies.
    Finally, would you mind getting down to specifics of your problem? From what I perceived, the JDBC tutorial and the API docs should provide all the information you need.

  • How to change the column value upto 68000 rows

    Hi,
    I want to change the column value.
    I have table called RefDoc
    Select distinct r.int_ref from refdoc r where r.int_ref like '\\dxb%'
    Int_Re__f
    \\dxb\Sample\BFE B777\2008\PO2025225.tif
    \\dxb\Sample\RO\SFR\26-01-2009j\RO2022098.pdf
    \\dxb\Sample\RO\SFR\26-01-2009j\RO2040831.pdf
    \\dxb\Sample\BFE B777\2008\PO2025253.tif
    \\dxb\Sample\RO\UM INV\26-01-2009\RO2018358.pdf
    up to 68000 rows
    I want to change to \\AUH instead of \\dxb.
    I want the table like
    Int_Re__f
    \\AUH\Sample\BFE B777\2008\PO2025225.tif
    \\AUH\Sample\RO\SFR\26-01-2009j\RO2022098.pdf
    \\AUH\Sample\RO\SFR\26-01-2009j\RO2040831.pdf
    \\AUH\Sample\BFE B777\2008\PO2025253.tif
    \\AUH\Sample\RO\UM INV\26-01-2009\RO2018358.pdf
    Thanks
    Nihar

    user REPLACE function and change it
    UPDATE refdoc
       SET int_ref = REPLACE(int_ref, '\\dxb\', '\\AUH\')
    WHERE int_ref like '\\dxb\%'

  • Return all the column values using the F4IF_INT_TABLE_VALUE_REQUEST

    Hi,
    How to return all the column values using the F4IF_INT_TABLE_VALUE_REQUEST?
    For example : if the row has 3 columns then after selecting the particular row, the RETURN_TAB internal table should contain all the three column values.
    Regards,
    Raghu

    Hi,
       Try the following...
    DATA : it_fields like help_value occurs 1 with header line.
    data: begin of w_vbap,
            vbeln      like vbap-vbeln,    
            posnr      like vbap-posnr,   
            werks      like vbap-werks,  
          end of w_vbap.
    data: i_vbap   like w_vbap   occurs 0 with header line,
             w_fields type help_value,
          i_dfies type table of dfies,
          i_return_tab type table of ddshretval with header line,
          i_field  type dfies.
      select vbeln posnr werks
          from vbap into table i_vbap up to 5 rows.
    if sy-subrc = 0.
       sort i_vbap by vbeln.
    endif.
      clear it_fields[] , it_fields.
      it_fields-tabname = c_vbap.
      it_fields-fieldname = 'VBELN'.
      it_fields-selectflag = c_on.
      append it_fields.
      it_fields-tabname = c_vbap.
      it_fields-fieldname = 'POSNR'.
      it_fields-selectflag = space.
      append it_fields.
      it_fields-tabname = c_vbap.
      it_fields-fieldname = 'WERKS'.
      it_fields-selectflag = space.
      append it_fields.
      loop at it_fields into w_fields.
        i_field-tabname   = w_fields-tabname.
        i_field-fieldname = w_fields-fieldname.
        i_field-keyflag   = w_fields-selectflag.
        append i_field to i_dfies.
      endloop.
      call function 'F4IF_INT_TABLE_VALUE_REQUEST'
        exporting
          retfield               = 'VBELN'
         window_title           = 'Select'
        tables
          value_tab              = i_vbap
          field_tab                = i_dfies
          return_tab             = i_return_tab
       exceptions
         parameter_error        = 1
         no_values_found        = 2
         others                 = 3
      read table i_return_tab into w_return_tab index 1.
      if sy-subrc = 0.
      endif.
    Regards,
    Srini.

  • Changing the column value

    Hi,
    I have to change the column values in a table. The values in the column are to be updated.
    For e.g. If the old value is
    "xxxxxxxxxx", I need to take that and update into "xxxyyyxxxx".
    The column values is so long as its a description field, so its a combination of many other table fields. Its just I need to add one more field.
    How can I do that? Any help appreciated.
    Thanks

    Hi,
    See this:
    I have got table with DESCRIPTION column which will be updated. Table structure is:
    SQL> DESC SOLD_ITEMS;
    Nazwa Warto&#347;&#263; NULL? Typ
    COMPONENT VARCHAR2(255)
    SUBCOMPONENT VARCHAR2(255)
    YEAR NUMBER(4)
    MONTH NUMBER(2)
    DAY NUMBER(2)
    DEFECTS NUMBER(10)
    DESCRIPTION VARCHAR2(200)
    Table description contains values from (component, year, month, day & defects) column. I would like to add subcomponent value to this column.
    SQL> SELECT * FROM SOLD_ITEMS;
    COMPONENT SUBCOMPONENT YEAR MONTH DAY DEFECTS DESCRIPTION
    graph bar 2006 4 3 10 graph 2006/4/3
    graph bar 2006 4 1 1 graph 2006/4/1
    search user search 2006 4 2 23 search 2006/4/2
    search user search 2006 4 1 54 search 2006/4/1
    search product search 2006 3 20 0 search 2006/3/20
    search product search 2006 3 16 3 search 2006/3/16
    6 wierszy zosta&#322;o wybranych.
    SQL> EDIT
    Zapisano plik afiedt.buf
    I use the SUBSTR and LENGTH function to place SUBCOMPONENT value between COMPONENT value and YEAR value. That's how I done it:
    1 UPDATE SOLD_ITEMS
    2* SET DESCRIPTION = SUBSTR(DESCRIPTION,1,LENGTH(COMPONENT)) || ' ' || SUBCOMPONENT || ' ' || SUBSTR(DESCRIPTION,LENGTH(YEAR))
    SQL> /
    6 wierszy zosta&#322;o zmodyfikowanych.
    SQL> SELECT DESCRIPTION FROM SOLD_ITEMS;
    DESCRIPTION
    graph bar 2006/4/3
    graph bar 2006/4/1
    search user search 2006/4/2
    search user search 2006/4/1
    search product search 2006/3/20
    search product search 2006/3/16
    6 wierszy zosta&#322;o wybranych.
    SQL> SPOOL OFF;
    Peter D.

  • How to add description of a column of a table in SQL Azure

    Hi
    I have some tables in my application database where there are descriptions added against certain columns. Needless to say they were done by using sp_addextendedproperty.
    Now I am trying to migrate the Database to SQL Azure. SQL Azure does not support sp_addextendedproperty.
    Hence I am not able to figure out how to add descriptions to those columns.
    Any help would be much appreciated.
    Thanks
    Soumyadeb

    Hello,
    Just as Latheesh post above, Windows Azure SQL database are not support extended stored procedures. That’s one of the limitations on SQL database, and I don’t know there is another way to achieve the same on Azure.
    Regards,
    Fanny Liu
    Fanny Liu
    TechNet Community Support

  • How to accessing current row report column value in Lov Query?

    Hi,
    which access methods (eg. bind variables, substitutions, ...) for getting the current row report column value can be used in the "Lov Query" property of a report column?
    As what I know of and what I have read on the forum there are no bind variables for the report columns. For the "Link Text" property it seems that the column values exist as substitution strings (#COLUMN_NAME#). But they don't work in the Lov Query. => And would be good because of a hard parse each time the Lov query is executed.
    The following post (Re: Simulating a correlated sub query in lov
    is showing a solution to use package variables for temporary storage of the referenced value, but the only problem with that solution is that if a new record is added with the "Add rows to tabular form" process the package variable still contains the value from the last queried row! Is there a way (variable, APEX package, ...) to determine if the lov query is executed for a new record so that the package can return null?
    I know that I could write the package in a way that the value is immediately cleared when lov_pkg.keyval is called (one time read), but then I would have to create several variables if I'm accessing the value multiple times in the query or in another query => I think an one time read solution would be very obscurely.
    Thanks for your help
    Patrick
    http://inside-apex.blogspot.com

    Hi Patrick,
    I agree that it's a waste to continually use Ajax to go back to the server to get the contents of a dynamic select list.
    There are no bind variables for any row item - but what you do have, as per my previous post, is the value of the data entered by the user in the first row. You can pass this into your application process (using get.add("VARIABLENAME", value)), which can use it to retrieve the correct LOV in your Ajax code - this will give you a "bind variable" that your process can use.
    What you could do, however, is generate hidden select lists on your page - one for each possible LOV list and replace the contents of the new row's select list with the contents of the appropriate hidden select list. This is easy to do with javascript (using innerHTML functions). Obviously, though, the usefulness of this depends on the number and size of the select lists.
    Even if you don't generate them to start with, you can keep a copy of any select lists returned by Ajax in the DOM for use on new rows. So, if you have retrieved a select list, you will have a copy of it in DOM which you can then copy into the new row. If you don't have the list in DOM, use Ajax to get it, store a copy of it and copy it into the new row.
    Which method you use will depend on the number/size of select lists needed. If they are few in number and/or size, I would suggest generating hidden lists. If they are large, use Ajax to get them once, store them and then retrieve them from the DOM when needed.
    There is another thread here where Arie recommends going to the server every time to make sure you get the most up-to-date data for the lists. If you want to follow this advice, for this reason, use get.add("VARIABLENAME", value) to pass the value to your process. If this is not an issue, you can use one of the other methods I outlined above.
    Regards
    Andy

  • To get the count of records and able to access the column value in a single

    Hi
    Is there any way to get the number of records in the query and access the column values
    e.g
    select count(*)
    from
    (SELECT department, COUNT(*) as "Number of employees"
    FROM employees
    WHERE salary > 25000
    GROUP BY department ) a
    This wil only get the Count, if i want to access each row from the inline view how can i do that.

    Your question is not clear.
    Are you looking for total record count as well as count by department ?
    Something like this?
    SQL>
    SQL> with temp as
      2  (
      3  select 1 dept ,10000 sal from dual union
      4  select 1 dept ,25100 sal from dual union
      5  select 1 dept ,30000 sal from dual union
      6  select 1 dept ,40000 sal from dual union
      7  select 2 dept ,10000 sal from dual union
      8  select 2 dept ,25100 sal from dual union
      9  select 2 dept ,30000 sal from dual union
    10  select 2 dept ,40000 sal from dual )
    11  select count(*) over( partition by 1 ) total_count,dept,
    12  count(*) over(partition by dept) dept_cnt  from temp
    13  where sal>25000;
    TOTAL_COUNT       DEPT   DEPT_CNT
              6          1          3
              6          1          3
              6          1          3
              6          2          3
              6          2          3
              6          2          3
    6 rows selected
    SQL>

Maybe you are looking for

  • Moving database 9i 32-bit to to be 10g on new hardware 64-bit

    Dear Gentlemen, I want to move a database 9.2.0.4.0 on windows server 2003 32-bit (Size=16GB) to be database 10G R2 on a new hardware with a windows server 2003 64-bit. can you explain the steps which i have to do to perform this issue?

  • Can't receive email - connection failure

    Since last nigh, the inbox in my Mail program (both computers) has had an alert icon. When activated, it says ... "There may be a problem with the mail server or network. Check the settings for account "XX" or try again. The server error encountered

  • Ipad and iphone connect launches iphoto

    Since updating to iOS 8, whenever I connect my iPhone or iPad to my MBP (running Yosemite), iPhoto launches. I want to stop this happening. iPhoto preferences are set to 'Connecting camera launches no application'. I can find no relevant setting in i

  • What is dummy G/L a/c

    Hi, hi, 1. Can any one please explain me “At the time of transactional data uploading do we need to create ”.dummy G/L . What is dummy G/L a/c.How maney we have to create. 2. If yes how many dummy G/L a/c do need to create. 3. Please provide me what

  • How can we add multiple editable region in template

    Hi, My issue is when I am going to create a new template I want to add multiple editable region in template and I want to use those editable region per page wise so that in page editor I will add different text for each page for those editable region