Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Anders Altberg
  Where is Anders Altberg?
 Uppsala
 Sweden
 Anders Altberg
 To: Roy Slough
  Where is Roy Slough?
 Potters Bar
 United Kingdom
 Roy Slough
 Tags
Subject: RE: Name string not working in SQL
Thread ID: 345266 Message ID: 345306 # Views: 51 # Ratings: 1
Version: Visual FoxPro 8 Category: Databases, Tables and SQL Server
Date: Tuesday, May 22, 2012 11:43:01 AM         
   


> >
> >
SELECT col1, col2, GETWORDNUM(cname,GETWORDCOUNT(cname)) FROM Customers ORDFER BY 3

>
> Thanks Anders, that is an excellent way to do it.
>
> If have found though that I still need a PADR() otherwise the field length for all rows is set to the length of the first records last word.
>
> SO what is needed is.
>
>
> SELECT IIF(lcompany,Cname,PADR(GETWORDNUM(cname,GETWORDCOUNT(cname)),20)) as SortName FROM customers
> 


Absolutely. Or, to make it a bit more general
 SELECT IIF(lcompany,Cname,PADR(GETWORDNUM(cname,GETWORDCOUNT(cname)),LEN(cname))) as SortName FROM customers
 or 
  CAST(GETWORDNUM(cname,GETWORDCOUNT(cname)) AS C(LEN(cname)))
 


-Anders

ENTIRE THREAD

Name string not working in SQL Posted by Roy Slough @ 5/21/2012 9:30:37 PM
RE: Name string not working in SQL Posted by Anders Altberg @ 5/22/2012 2:29:49 AM
RE: Name string not working in SQL Posted by Roy Slough @ 5/22/2012 9:26:01 AM
RE: Name string not working in SQL Posted by Anders Altberg @ 5/22/2012 11:43:01 AM
RE: Name string not working in SQL Posted by Mike Yearwood @ 5/22/2012 3:49:58 PM
RE: Name string not working in SQL Posted by Roy Slough @ 5/22/2012 4:02:45 PM
RE: Name string not working in SQL Posted by Mike Yearwood @ 5/22/2012 8:21:17 PM
RE: Name string not working in SQL Posted by Roy Slough @ 5/24/2012 8:48:35 AM
RE: Name string not working in SQL Posted by Mike Yearwood @ 5/24/2012 4:59:18 PM
RE: Name string not working in SQL Posted by tushar @ 5/24/2012 8:08:37 PM
RE: Name string not working in SQL Posted by Samir Ibrahim @ 5/30/2012 9:05:13 PM