Showing posts with label sqlplus. Show all posts
Showing posts with label sqlplus. Show all posts

Friday, March 9, 2012

Formating column widths with SQLPlus

How do you set column widths to (20 for example) using SQLPlus.Originally posted by rwj7p
How do you set column widths to (20 for example) using SQLPlus.
For a numeric column:
COLUMN colname FORMAT 9999999999.999

For a varchar2 column:
COLUMN colname FORMAT A20

You can also define different default wisth for ALL number columns:

SET NUMWIDTH 20|||Thanks, just what I was needing

Sunday, February 19, 2012

format column lengths

In Oracle sqlplus I always had a login.sql with statements like

column bldg_id format a8

which I could also use interactively on the sqlplus command line.

How can I do this in transact-sql ?

As far as I know, there is no equal command in SQL Server.

But for simple format purpose, you can try -Y or -y parameter for sqlcmd.exe

For more info, pls try sqlcmd /?

Thanks,

Zuomin
|||

You can use BCP with format files, where you can control lot of options..

See BCP on BOL

|||

Thank you both, but I'm just running the transact-sql available through Enterprise to SQL server, and I don't know what BCD is.

I learned I can do this:

oracle: col id format a8
transact-sql: select cast( id as char(8) )

|||Also, don't overlook OSQL if you need a handy command access. I've gotten more little jobs done with a good batch file and some OSQL than I can count.

John V. McCarthy