How to trim the output gererated by "select..table" 
Author Message
 How to trim the output gererated by "select..table"
I'm wondering whether there is a way to trim the output generated by
"select .. table".

suppose table t(name(char(100),vary varchar(100))

if select * from t, it came out with a long row with 100 + 100 width,
how can I specify the width is 30 + 30?

and any way used to get the maximum length from those columns domained
by  varchar(for above table, the vary may has length from 0-100)?

Thanks

--
John
Toronto



Sun, 17 Jul 2005 21:30:58 GMT
 How to trim the output gererated by "select..table"

John wrote on Wednesday 29 January 2003 14:30:

Quote:
> I'm wondering whether there is a way to trim the output generated by
> "select .. table".

> suppose table t(name(char(100),vary varchar(100))

> if select * from t, it came out with a long row with 100 + 100 width,
> how can I specify the width is 30 + 30?

This would truncate the columns accordingly:

SELECT VARCHAR(name, 30), VARCHAR(vary, 30)
FROM   t;

Quote:
> and any way used to get the maximum length from those columns domained
> by  varchar(for above table, the vary may has length from 0-100)?

hmm??

--
Knut Stolze
Information Integration
IBM Germany / University of Jena



Sun, 17 Jul 2005 23:06:17 GMT
 How to trim the output gererated by "select..table"

Quote:

> John wrote on Wednesday 29 January 2003 14:30:

> > I'm wondering whether there is a way to trim the output generated by
> > "select .. table".

> > suppose table t(name(char(100),vary varchar(100))

> > if select * from t, it came out with a long row with 100 + 100 width,
> > how can I specify the width is 30 + 30?

> This would truncate the columns accordingly:

> SELECT VARCHAR(name, 30), VARCHAR(vary, 30)
> FROM   t;

> > and any way used to get the maximum length from those columns domained
> > by  varchar(for above table, the vary may has length from 0-100)?

> hmm??

Thank you, Knut Stolze.

the second question is , since vary defined as varchar(100), so the
length of this column may have length from 0-100, suppose

select * from t, it came out with

name       vary
foooooo    65characters
f0000      96charachters
f00        10charachers

what I want is how to capture the longest length of vary from all
records(in this case the second row has longest length) ?

Thanks again



Mon, 18 Jul 2005 02:36:31 GMT
 How to trim the output gererated by "select..table"
You can find the width of the largest value in column name with this query:

    select max(length(name)) from t

Quote:


> > John wrote on Wednesday 29 January 2003 14:30:

> > > I'm wondering whether there is a way to trim the output generated by
> > > "select .. table".

> > > suppose table t(name(char(100),vary varchar(100))

> > > if select * from t, it came out with a long row with 100 + 100 width,
> > > how can I specify the width is 30 + 30?

> > This would truncate the columns accordingly:

> > SELECT VARCHAR(name, 30), VARCHAR(vary, 30)
> > FROM   t;

> > > and any way used to get the maximum length from those columns domained
> > > by  varchar(for above table, the vary may has length from 0-100)?

> > hmm??

> Thank you, Knut Stolze.

> the second question is , since vary defined as varchar(100), so the
> length of this column may have length from 0-100, suppose

> select * from t, it came out with

> name       vary
> foooooo    65characters
> f0000      96charachters
> f00        10charachers

> what I want is how to capture the longest length of vary from all
> records(in this case the second row has longest length) ?

> Thanks again



Mon, 18 Jul 2005 02:58:04 GMT
 
 [ 4 post ] 

 Relevant Pages 

1. max of ("...","...","..")

2. Recordset via "TRIM"

3. "Selected table lacks required numeric columns"

4. "compress" transaction tables within a select

5. Slow "select" in big table

6. Error Message "cannot access selected table"

7. "missing table", but "table" is embedded select stmt

8. "missing table", but "table" is embedded select stmt (long)

9. QA "output query" option

10. SP outputs "Doing It"

11. ""URGENT "" Inserting "For xml explicit" results to a Temp table

12. "No output generated during replication"


 
Powered by phpBB® Forum Software