Solved

FoxPro Alias Table Name

Posted on 2013-10-28
7
1,050 Views
Last Modified: 2013-10-29
Hello Experts!

How can I shorten the name of a table?
For Example:

SELECT *;
FROM Long_Table_Name LTN;

In SQL you can just put a space and then LTN for the short name, how do you do this in FoxPro?

Thanks,
Mark
0
Comment
Question by:smithmrk
  • 3
  • 2
  • 2
7 Comments
 
LVL 41

Accepted Solution

by:
pcelba earned 500 total points
ID: 39606621
Yes, this works for FoxPro same way as on SQL Server.

In addition to this you may open any table with a short alias directly

USE d:\path\Long_Table_Name ALIAS LTN
SELECT * FROM LTN

One more hint: Don't use M as short alias because it collides with  M.  memory variable prefixes.
0
 

Author Closing Comment

by:smithmrk
ID: 39606722
Thanks!
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 39606872
Besides USE ALIAS you can also use alias namesin SQL, as you initially wrote, with or without AS keyword:

SELECT LTN.fieldx, ATN.fieldy;
FROM Long_Table_Name LTN ;
LEFT JOIN Another_Table_Name AS ATN;
ON LTN.id = ATN.LTNid

Open in new window


Besides M you should also aviod a-j as those are reserved for workarea 1 to 10 for historical reasons (backward compatibility with 2.x versions, if not even older).

Bye, Olaf.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:smithmrk
ID: 39606911
Thanks for the additional information Olaf!

Mark
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 39606950
You're welcome.

Another hint: If you're having problem with a query length, especially the WHERE clause: take a look at SYS(3055)

http://msdn.microsoft.com/en-us/library/43cab295(v=vs.80).aspx

Bye, Olaf.
0
 
LVL 41

Expert Comment

by:pcelba
ID: 39607058
Just to clarify:  Local (short) aliases a - j can be used in SQL commands without restrictions. The local alias has precedence to any other language element and historical reasons cannot apply here.  Alias m can also be used in SQL commands but then you cannot distinguish between table (aliased as m) column and memory variable of the same name.

FoxPro has no reserved keywords and you may use language elements as variable and column names almost freely (with some restrictions and surprises, of course)... Variables a - j do not cause any problems.

SYS(3055) can be useful but I did not use it yet - my SQL commands are too short probably. But to overview the list of available FoxPro functions is geed practice. :-)
0
 

Author Comment

by:smithmrk
ID: 39608611
WOW, Thanks for all the Information!
I really appreciate the knowledge you folks have as I try to be a better programmer!

Thanks again for all your help in the past, now, and defiently in the future!

Mark
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Convert Word Doc or PDF file to VFP FRX report 9 1,821
filtering a list vfp 4 162
convert/ import XLSB / vfp9 5 74
filling in gaps in tables vfp 9 78
Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

947 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

22 Experts available now in Live!

Get 1:1 Help Now