Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 output has large column of spaces

Author  Topic 

footohi
Starting Member

10 Posts

Posted - 2006-05-24 : 17:09:28
This one is driving me nuts...try this -

USE NORTHWIND
SET NOCOUNT ON
select ORDERID,
REPLACE(CONVERT(char,ORDERDATE,101),'/',''),
'01'
from ORDERS

I'm doing this in an output statement on my table, why is the 2nd column so wide?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-05-24 : 17:18:53
The REPLACE function is causing this. Try this instead:

select ORDERID, CONVERT(char(8), REPLACE(CONVERT(varchar(10), orderdate, 101), '/', '')), '01'
from ORDERS

You could also use SUBSTRING or various other character functions to fix this.

Tara Kizer
aka tduggan
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-05-24 : 17:20:19
[code]
use NORTHWIND
set nocount on

select
ORDERID,
left(replace(convert(varchar,ORDERDATE,101),'/',''),8),
'01'
from
ORDERS


[/code]

CODO ERGO SUM
Go to Top of Page
   

- Advertisement -