Solved

Line up function returned string...

Posted on 2014-10-13
2
113 Views
Last Modified: 2014-10-13
The sql below returns something like:

Jack Smith            <-- has orders
Robert Nissan           <-- has orders

(in a combo box)

I want to line up <-- has orders portions in:

       SQL.ExecQuery("SELECT CustomerID, FirstName + ' ' + LastName + '     ' +" &
                     " dbo.fnHasOrders (CustomerID) as CustName From tblCustomers")


by having variable number of blank spaces instead of just '     ' above.

Let's say if we start this string (<-- has orders) at 50th position. I know it possibly will not to be exactly in line but it will be good enough.
0
Comment
Question by:Mike Eghtebas
2 Comments
 
LVL 15

Accepted Solution

by:
Haris Djulic earned 500 total points
ID: 40379157
You can try like this :

 SQL.ExecQuery("SELECT CustomerID, substring(FirstName + ' ' + LastName + '                                                     ',1,50) +" &
                     " dbo.fnHasOrders (CustomerID) as CustName From tblCustomers") 

Open in new window


Basically, you add up extra blanks and then you substing it to 50 places..
0
 
LVL 33

Author Closing Comment

by:Mike Eghtebas
ID: 40379176
Thank you.
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how the fundamental information of how to create a table.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now