Re: ADO return varchar string with space trimmed



Cast to char(10) work. Can you explain why? any documentation link?

But using varchar also working in different database. Is that a SQL server
config problem?



"Daniel Crichton" wrote:

> wdwedw wrote on Thu, 28 Jul 2005 12:42:10 -0700:
>
> > I have a stored procedure like this:
> > select CASE WHEN LEN(D1) < = 10
> > THEN D1 + REPLICATE(' ', 10 - len(D1))
> > ELSE LEFT(D1,10)
> > END AS D1
> > from table1
> >
> > When ADO retrieved the record in VB, the appended spaces were trimmed! I
> > can work around with REPLICATE(N' ', 10 - len(D1)). But what's wrong?
>
> A varchar defined field will strip appended spaces. CAST it as a char(10)
> and the spaces will remain.
>
> Dan
>
>
>
.



Relevant Pages

  • Re: SQL Backend
    ... SELECT ID, ComputerID, cast (NICManufacturer as varchar) as ... cast (DNSServer1 as varchar) as DNSServer1, ... cast (WINSServer1 as varchar) as WINSServer1, ...
    (microsoft.public.fox.helpwanted)
  • Re: SQL Backend
    ... SELECT ID, ComputerID, cast (NICManufacturer as varchar) as ... cast (DNSServer1 as varchar) as DNSServer1, ... cast (WINSServer1 as varchar) as WINSServer1, ...
    (microsoft.public.fox.helpwanted)
  • Re: SQL Backend
    ... SELECT ID, ComputerID, cast (NICManufacturer as varchar) as ... cast (DNSServer1 as varchar) as DNSServer1, ... cast (WINSServer1 as varchar) as WINSServer1, ...
    (microsoft.public.fox.helpwanted)
  • Re: SQL Backend
    ... it to work is to edit SQL query behind the view. ... SELECT ID, ComputerID, cast (NICManufacturer as varchar) as ... cast (WINSServer1 as varchar) as WINSServer1, ...
    (microsoft.public.fox.helpwanted)
  • Re: SQL Backend
    ... cast (NICManufacturer as varchar) as NICManufacturer, ... cast (DNSServer1 as varchar) as DNSServer1, ... cast (WINSServer1 as varchar) as WINSServer1, ...
    (microsoft.public.fox.helpwanted)