I need a query that returns the average amount of characters for a text colum in MS SQL.

I need a query that returns the average amount of characters
for a text colum in MS SQL.
Could someone show me how?

Sorted, i need the
DATALENGTH
function

Similar Messages

  • I need a query that selects the amount of records for each day in a table.

    I need a query that selects the amount of records for each
    day in a table.
    Eg the result would be:
    date 1 14
    date 2 3
    etc
    Any ideas?

    sorted:
    SELECT count([commentID]),convert(varchar, dateAdded, 112)
    FROM COMMENTSgroup by convert(varchar, dateAdded,
    112)

  • Need a Query that Returns both Column Name with Column Data

    Hi,
    Hope someone can assist quite quickly. I'm after a query that will return me both column name together with column data, i.e
    Table: APP_INFO
    COL1  - currently has the value of 10
    COL2  - currently has the value of 'HELLO'
    COL3  - currently has the value of 'QWERTY'
    COL4  - currently has the value of 2000Query I'm after is to return the following result set: [actual column name, actual column data]
    COL1,10
    COL2,'HELLO',
    COL3,'QWERTY'
    COL4,2000
    Any help would be much appreciated.
    Thanks.
    Tony.

    Like this ?
    SQL> select empno, ename, deptno from emp where deptno = 10;
         EMPNO ENAME          DEPTNO
          7782 CLARK              10
          7839 KING               10
          7934 MILLER             10
    SQL> select decode(t.id,1,'EMPNO',2,'ENAME',3,'DEPTNO') COLNAME,
      2  decode(t.id,1,to_char(empno),2,ename,3,deptno)
      3  from (select emp.*, rownum rn from emp
      4  where deptno = 10) emp, (select rownum id from dict where rownum <=3) t
      5  order by emp.rn, t.id
      6  /
    COLNAM DECODE(T.ID,1,TO_CHAR(EMPNO),2,ENAME,3,D
    EMPNO  7782
    ENAME  CLARK
    DEPTNO 10
    EMPNO  7839
    ENAME  KING
    DEPTNO 10
    EMPNO  7934
    ENAME  MILLER
    DEPTNO 10
    9 rows selected.Rgds.

  • I need sorting VI that returns the sorted array element's positions in the unsorted array

    I need a VI that will very quickly (n log n) sort a 1D array of doubles.  This VI should not only output the sorted array, but for each of the sorted array elements, it should also output that sorted array element's position in the unsorted array.  So for example if the input array were:
    unsorted_array
    4.1
    2.3
    7.0
    5.6
    10.2
    Then the output arrays would be:
    sorted_array
    2.3
    4.1
    5.6
    7.0
    10.2
    indices_array
    1 (the value 2.3 is located at position 1 in the unsorted_array)
    0 (the value 4.1 is located at position 0 in the unsorted_array)
    3 (the value 5.6 is located at position 3 in the unsorted_array)
    2 (the value 7.0 is located at position 2 in the unsorted_array)
    4 (the value 10.2 is located at position 4 in the unsorted_array)
    This way I could generate the sorted_array using just the indices_array and the unsorted_array.  Has anyone written a nifty piece of code to do this?  I did some research on (n log n) sorting algorithms but most of them use recursion which I don't know how to do in LabVIEW.  It would also be nice to have an algorithm like this that could sort an array of strings.
    cheers,
    Richard

    Try something like the attached example (LabVIEW 7.0). I think it does what you need.
    (To understand the code, it is important to know that arrays of clusters are sorted by the first element in the cluster).
    Sort array itself sorts also array of strings, so you could just substitute, keeping the rest of the code the same.
    Sort array uses a variation of quicksort, so it should have about NlogN complexity.
    (If you think you only need the array of indices to later generate the sorted array, it does not make much sense to even do it. To get the indices, you need to sort the array anyway. You should just sort the plain array directly.
    Message Edited by altenbach on 07-13-2005 03:47 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    SortAndIndex.vi ‏26 KB

  • Updating a table with a query that return multiple values

    Hi,
    I'm trying to update a table which contain these fields : ItemID, InventoryID, total amounts
    with a query that return these values itemId, inventoryid and total amounts for each items
    Mind you, not all the rows in the table need to be updated. only a few.
    This what i wrote but doesn't work since the query return multiple values so i can't assign it to journalAmounts.
    UPDATE [bmssa].[etshortagetemp]
    SET JournalAmounts = (SELECT sum(b.BomQty) FROM [bmssa].[Bom] b
    JOIN [bmssa].[SalesLine] sl ON sl.ItemBomId = b.BomId
    JOIN [bmssa].[SalesTable] st ON st.SalesId = sl.SalesId
    WHERE st.SalesType = 0 AND (st.SalesStatus IN (0,1,8,12,13)) AND st.DataAreaId = 'sdi'
    GROUP BY b.itemid, b.inventdimid)
    Any advise how to do this task?

    Remember that link to the documentation posted above that explains exactly how to do this. When you read it which part exactly were you having trouble with?

  • Bex query that returns variable number of columns based upon variable value

    I have a request to create a query that, at excution time, has a variable for 'nbr of months', and based on the value entered by the user, returns data for only the specified number of months. Value that can be entered can vary from 1 to 12. A simple example is, if the user enters 1, then they would only want to see one column, and if they entered 6, then they'd like to see 6 columns in the workbook.  All suggestions on how to implement this dynamic columns on a workbook will be appreciated.
    Thanks.
    BN

    Hi,
    Do this->
    1) first create a New Structure in Rows-> Place your New Selection and drag your KF.
    2) Nw Create a New Formual under this structure. Now Create a Formula variable ( "ZFVXXX")with user-entry and ready for input and dimension as NUmber. and place in formula area. And hide this formula.
    3)Now Create a New Customer-Exit variable on 0CALMONTH name as "ZCECMON" with following atrribute->Mandatory, Range(Interval) and remove check for Ready for entry.
    4)Drag your 0CALMONTH in Rows above That Structure and restrict it to "ZCECMON".
    5) Now go to CMOD and write this code.
    INCLUDE ZXRSRU01 *
    DATA: L_S_RANGE TYPE RSR_S_RANGESID. 'In global area
    DATA: LOC_VAR_RANGE LIKE RRRANGEEXIT. 'In global area
    DATA: zmonth like /bi0/0calmonth.
    CASE I_VNAM.
    WHEN 'ZCECMON'.
    IF i_step = 2.
    LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE
    WHERE VNAM = 'ZFVXXX'.
    zyear = sy-datum(4).
    zmonth = sy-datum+4(2).
    l_s_range-low = zmonth.
    zmonth = zmonth + loc_var_range-low.
    l_s_range-HIgh = zmonth.
    l_s_range-sign = 'I'.
    l_s_range-opt = 'BT'.
    APPEND l_s_range TO e_t_range.
    ENDIF.
    ENDCASE.
    6) activate the porject and go to rsrt and run there first.
    Regards,
    San!
    Message was edited by: San!

  • Available webservice/tool that returns the physical qry from logical qry?

    Is there any obiee webservice or program that returns the physical query by receiving the logical query as a parameter ?
    What we are looking for is to have a "process" that use the logic that bi server has to resolve the reports using the metadata (rpd) to derive the physical query.
    It should be like the logic that is behind the "issue direct sql" function. But instead of pasting the logical query into the text box we will be passing it as a parameter in a custom process.
    Many thanks,
    Georgina

    800 by 800 pixel file @ 300 DPI:
    Guide @ random position:
    800 by 800 pixel file @ 300 DPI:
    Guide @ 40,341 mm
    One selection drawn from the left, one from the right.
    The border of the selection should be on the same left-right-position, but differs about one pixel (these are all zoomed in).

  • What is the Function MOdule that returns the fields in database table order

    Hello Folks
      I have a dynamic internal table with fields ( which are not in order). I want to display them in the order of which they are present in the database table? Is there any function module that returns the fields in database order?
    FAQ. Please search before posting your question.
    Edited by: Suhas Saha on Oct 10, 2011 10:19 PM

    Hi,
    You can use this BAPI.
    <b>BAPI_SALESORDER_GETLIST</b>
    Reward if useful.
    Regards,
    Vimal

  • I forgot my Apple ID password. and I tried to rest it but I don't get a reset email to change the password. What do I need to do to return the account. (I need the specified account because I bought apps with it.)

    I forgot my Apple ID password. and I tried to rest it but I don't get a reset email to change the password. What do I need to do to return the account. (I need the specified account because I bought apps with it.)

    The Best Alternatives for Security Questions and Rescue Mail
        a. Send Apple an email request at: Apple - Support - iTunes Store - Contact Us.
        b. Call Apple Support in your country: Customer Service: Contact Apple support.
        c. Rescue email address and how to reset Apple ID security questions.

  • I need a script that copies the filename into the file

    I need a script that copies the filename into 4th column of each line in the text doc file.
    I have over 2000 different file names each containing 6 columns and ~50-100 rows.
    I can do this manually using this script:
    awk '{print $1"\t"$2"t\"$3"\t <name> \t"$6}'
    But I would like an automation command or script. Is there any command that I can use instead of <name> that will copy the filename into the column?
    Thanks
    Monica

    Oops, I forgot the redirect to a file. It's not a good idea to edit files in place. A script could fail and you're left with at least one file ruined. It's better to create new files then delete the old files.
    for file in *; do
        while read col1 col2 col3 col4 col5 col6; do              
            printf "%s\t%s\t%s\t%s\t%s\n" $col1 $col2 $col3 $file $col6
        done < $file > n$file
    done
    You could narrow the files listed such as
    for file in *.tsv
    and redirect the new files to another directory. Such as
    done < $file > /absolute/path/to/directory/$file

  • SQL query that returns exclusive rows from groups

    I'm using modified scott/tiger data for this.
    I've got two tables
    DEPT_X
    DEPTNO     DNAME             LOC     CODE_ID     SUB_DEPTNO
    10     ACCOUNTING     NEW YORK 111     101
    10     SALES             ATWN      111     102
    10     SALES             BTWN      112     103
    20     RESEARCH     DALLAS      111     201
    20     RESEARCH     CTWN      111     202
    30     SALES             CHICAGO      111     301
    40     OPERATIONS     BOSTON      112     401and
    BI_PD
    CODE_ID     PD_TYPE     BI_TYPE
    111          -1
    112     -1     I want to write a query that joins the code_ids of the two tables and lists out either only the records from DEPT_X who's code_ids have a -1 in the PD_TYPE(112) column and none of the code_ids that have a -1 in the BI_TYPE(111) column for each department or if that department has code_ids for the BI_TYPE (111), list out those rows. So for Deptno 10 you'll only get the row with SUB_DEPTNO = 103. But if for that DEPTNO= 20 you'll get the rows for both SUB_DEPTNO = 201 and 202.
    So the result should look like
    DEPTNO   SUB_DEPTNO
    10          103
    20          201
    20          202
    30          301.
    Basically I just want rows from each department that have code_ids = 111 not to show up if there are code_ids = 112.
    What is the query to do this?
    Message was edited by:
    user623359
    Message was edited by:
    user623359
    Message was edited by:
    user623359
    Message was edited by:
    user623359
    Message was edited by:
    user623359

    One way could be:
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
    With the Partitioning, OLAP and Data Mining options
    SQL> with dept_x as (
      2      select 10 deptno, 'ACCOUNTING' dname, 'NEW YORK' loc, 111 code_id, 101 sub_deptno from dual
    union all
      3      select 10, 'SALES', 'ATWN', 111, 102 from dual union all
      4      select 10, 'SALES', 'BTWN', 112, 103 from dual union all
      5      select 20, 'RESEARCH', 'DALLAS', 111, 201 from dual union all
      6      select 20, 'RESEARCH', 'CTWN', 111, 202 from dual union all
      7      select 30, 'SALES', 'CHICAGO', 111, 301 from dual union all
      8      select 40, 'OPERATIONS', 'BOSTON', 112, 401 from dual ),
      9  --
    10  bi_pd as(
    11      select 111 code_id, null pd_type, -1 bi_type from dual union all
    12      select 112, -1, null from dual),
    13  --
    14  t as(
    15      select a.deptno,a.sub_deptno from dept_x a, bi_pd b
    16      where a.code_id = b.code_id and b.pd_type = -1)
    17  --
    18  select a.deptno,a.sub_deptno
    19  from dept_x a, bi_pd b
    20  where a.code_id = b.code_id and b.bi_type = -1 and 
    21        (a.deptno) not in (select deptno from t)
    22  union
    23  select deptno,sub_deptno from t;
        DEPTNO SUB_DEPTNO
            10        103
            20        201
            20        202
            30        301
            40        401

  • BAPI OR RFC THAT RETURNS THE VALUE TABLE CONTENTS THAT IS SPECIFIED IN DOM

    HI ALL,
    i have requirement of BAPI  or RFC that returns the value table contants(text table) in CRM..
    for ex:
      if i  pass the dataelement or domain or checktable as input parameter,could i get the contents of its text table associated with it....
    please if there is way help me on this..
    thanks and regards,
      goutham,

    Check these FM
    RFC_READ_TABLE
    RFC_GET_TABLE_ENTRIES

  • How come my macbook air has so little space. I deleted everything that I don't need and everything that has the most space I'm told NOT to delete. Everything I find is in either KB or very low MB.

    How come my macbook air has so little space. I deleted everything that I don't need and everything that has the most space I'm told NOT to delete. Everything I find is in either KB or very low MB.

    Check what is in your SSD/ storage on your macbook  Apple Icon >   about this mac > more info >  STORAGE tab on top
    recommend handy useful APPS such as :
    Disk Expert
    https://itunes.apple.com/us/app/disk-expert/id488920185?mt=12
    Disk Map
    https://itunes.apple.com/us/app/disk-map/id715464874?mt=12
    dont need them, but theyre very useful.
    also the best is DAISY DISK
    https://itunes.apple.com/app/daisydisk/id411643860?mt=12&ign-mpt=uo%3D4
    See here for answer about the OTHER which is taking up space:
    http://pondini.org/TM/30.html
    and here:
    http://pondini.org/OSX/DiskSpace.html
    See Kappys excellent note on the rest of “other” files taking up your space:
    What is "Other" and What Can I Do About It?
    see here:
    Your Solid State Drive and having enough space inside your Macbook Air & Pro
    Solid State Drive usage premise, or the “more space / upgrade SSD” question
    There have been questions posed and positions taken by many people who are trying to use their Macbook Air or Pro’s solid state drive (SSD) as a mass media storage device, for either pictures, videos, massive music collections or all three combined; but this should not be the working premise of a ‘limited’ SSD and its use.
    In which, it’s the case of those users with either 128GB, 256GB, or even 512GB of internal SSD space, that have or are running “out of space”, that questions are raised. The immediate premise of some users can sometimes be “(how to / if) upgrading my SSD” when in fact in nearly all instances another approach is the logical and sensible one that needs to be looked into and exercised.
    Any Macbook containing a SSD should be idealized as a ‘working platform’ notebook containing all your applications, documents, and weekly or bi-weekly necessary files. All collections of media files such as pictures, music, and videos, unless directly needed should be kept off the notebook and on an external hard drive or likewise. While the ‘working platform’ premise is also the case with larger internal conventional hard drives of 1TB+, its implementation isn't as critical except in terms of data protection.
    Realistically, you should at most coordinate roughly 20 to 25% of your total SSD space to all audio-video personal use media (picture / music / video collections), leaving the remaining amount on an external HD.
    Nobody should consider any notebook a data storage device at any time under any circumstance, rather a data creation, sending, and manipulation device; and in the case of a SSD, this is more important for purposes of having sufficient working space on the SSD and reducing SSD ‘bloat’ in which cases someone is wrongly attempting to use the SSD space as a large media storage nexus.
    The rare exception to the collective usage and premise of SSD use in which a much larger SSD is truly needed are for those in video and photography professions that require both the extremely fast speeds of the SSD and the onboard storage for large and or many video and photography files. However this also falls under the premise of a ‘working platform’ for such peoples rather than the intent of many who are using the SSD as passive and static data storage for media files very infrequently needed or accessed.
    All on-notebook data collections should be logically approached as to necessity, and evaluated as to whether it is active or passive data that likely doesn’t need to be on the notebook, allocations of space-percentages to as-needed work and use, apportioning space for your entertainment media, and questioning whether it should it be on the notebook for more than short-term consumption.
    Considerations should be made in the mind of any user in differentiating the necessary system data (System hub) comprising the Mac OSX, applications, necessary documents that both must and should be on your internal SSD, and that of the users personal data (Data hub) comprising created files, pictures, music, videos, PDF files, data created or being created and otherwise, that likely unless being used soon or often should be parked on an external hard drive for consumption, or temporarily loading onto the internal SSD.
    You both can and should purchase whichever SSD size you need or see fit, but even in the case of the largest of SSD, unless use-considerations are made, and SSD spaces are allocated as should be the case indicated above, one can easily and immediately run into this quandary of “needing more internal SSD space”, in which instance a different approach in usage must then be implemented.
    However it is almost always the case, that such large media files are wanted to be stored internally rather than actually needed, in which case the external HD is both prudent as well as necessary. Additionally costs per MB are infinitely less on an external HD than an internal SSD in any consideration of data expansion needs.
    A Professional Example
    In the case of a Macbook Air or Macbook Pro Retina with ‘limited’ storage on the SSD, this distinction becomes more important in that in an ever rapidly increasing file-size world, you keep vital large media files, pics, video, PDF collections, music off your SSD and archived on external storage, for sake of the necessary room for your system to have free space to operate, store future applications and general workspace. 
    You should also never be put in the position of considering “deleting things” on your Macbook SSD in order to ‘make space’. This is especially what your external HD is for.
    Professionals who create and import very large amounts of data have almost no change in the available space on their notebooks internal SSD because they are constantly archiving data to arrays of external or networked HD.
    Or in the case of the consumer this means you keep folders for large imported or created data and you ritually offload and archive this data for safekeeping, not only to safeguard the data in case your Macbook has a SSD crash, or gets stolen, but importantly in keeping the ‘breathing room’ open for your notebook to operate, expand, create files, add applications, for your APPS to create temp files, and for general operation.
    Slim USB3 1TB external hard drive
    External Hard Drives
    External hard drives are both extremely cheap and regardless of the size of your internal SSD (or even internal hard drive if the case), you need an external hard drive with your SSD equipped Macbook for several reasons:
    1. Data backup and protection.
    2. Redundancy for important data.
    3. Necessitated ideal space for large media files for collections of pictures, videos, and music etc.
    While ever changing in price, typical portable 2.5” external hard drives in USB3 run roughly $65 for 1TB or $120 for 2TB small portable USB3 hard drives. Such drives range in thickness between 5mm and 15mm, with recent improvements in storage of 500GB drives in 5mm profiles.
    There is almost no premise in which a small 12mm thick 1 Terabyte USB hard drive cannot be taken along with any Macbook as an external large storage extension inside any Macbook carry case or pouch. Typically such external HD profiles are not much bigger than a deck of cards.
    External hard drives are a foregone necessity for purchase with any Macbook for at the very least Time Machine backups, data redundancies, and ideally for large media storage.

  • BAPI that returns the PurchasingOrg of given user.

    Hi all,
    I'm trying to find BAPI that returns the PurchasingOrg of given user.
    Any help will be very appreciated.
    Thanks,
    DannyL

    >
    Danny Leviev wrote:
    > Hi all,
    >
    > I'm trying to find BAPI that returns the PurchasingOrg of given user.
    >
    > Any help will be very appreciated.
    >
    > Thanks,
    >
    > DannyL
    Hi dear,
    Can u explin in deatails what exactly you are looking for??

  • I submitted my information to receive a replacement 1st generation nano but somehow did not notice what steps I needed to take to return the Ipod to Apple. What needs to be done after submitting the serial number information online?

    I submitted my information to receive a replacement 1st generation nano but somehow did not notice what steps I needed to take to return the Ipod to Apple. What needs to be done after submitting the serial number information online in order to obtain a replacement?

    They're supposed to send you a box with shipping instructions which you then use to send them your 1st generation iPod, however, I've been waiting a month for my box and can't figure out why I have not received it

Maybe you are looking for