Results 1 to 15 of 15

Thread: SQL statement which returns the length of a table field in the DB

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Location
    greece athens
    Posts
    115

    Question SQL statement which returns the length of a table field in the DB

    well is there a sql statement so to obtain the length ( in bytes ) of a spesific table field from data base ?

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: SQL statement which returns the length of a table field in the DB

    What do you mean by "length of a table field"?

    Are you asking about a varchar field, and how many characters it is has been set to?

  3. #3
    Frenzied Member brin351's Avatar
    Join Date
    Mar 2007
    Location
    Land Down Under
    Posts
    1,293

    Re: SQL statement which returns the length of a table field in the DB

    try DATALENGTH

    SELECT DATALENGTH(columnName) AS xxx FROM table ...etc

    the result depends on the column datatype

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Location
    greece athens
    Posts
    115

    Re: SQL statement which returns the length of a table field in the DB

    i mean for example if field_name is varchar2(250) , i need a select statement so to have as result 250

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: SQL statement which returns the length of a table field in the DB

    Quote Originally Posted by chriskaza81
    i mean for example if field_name is varchar2(250) , i need a select statement so to have as result 250
    Ok, that was my question.

    Did you try what brin351 suggested?

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Location
    greece athens
    Posts
    115

    Re: SQL statement which returns the length of a table field in the DB

    what do you mean brin351???? i use oracle

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: SQL statement which returns the length of a table field in the DB

    Post #3

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Location
    greece athens
    Posts
    115

    Re: SQL statement which returns the length of a table field in the DB

    so do you know how can i do it is there any way???

  9. #9
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: SQL statement which returns the length of a table field in the DB

    Are you talking about using the Desc tablename as in SQL? If so that is not avail from VB (or C# or C or C++). Search the forums I have posted a method for returning table field sizes using Oracle and VB.
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  10. #10
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: SQL statement which returns the length of a table field in the DB

    This is what I was referring to by brin351 and Post #3
    Quote Originally Posted by brin351
    try DATALENGTH

    SELECT DATALENGTH(columnName) AS xxx FROM table ...etc

    the result depends on the column datatype
    Apparently it is moot, as Gary has stated it probably won't work, but I just wanted to clear that up.

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Location
    greece athens
    Posts
    115

    Re: SQL statement which returns the length of a table field in the DB

    yes i want to obtain table field size is there any select statement i can do that??

  12. #12
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: SQL statement which returns the length of a table field in the DB

    Look at this thread http://www.vbforums.com/showthread.php?t=459103

    Last post (I think last any way). I posted a method of getting the data back from an Oracle DB.
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  13. #13

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Location
    greece athens
    Posts
    115

    Re: SQL statement which returns the length of a table field in the DB

    ok thanks a lot

  14. #14
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: SQL statement which returns the length of a table field in the DB

    Does that work for you? Is this question resolved?

  15. #15

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Location
    greece athens
    Posts
    115

    Re: SQL statement which returns the length of a table field in the DB

    yes thnks !!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width