Re: How can i get the "true" name of an aliased field?



ekkehard.horner wrote:
Quick and dirty example:

Dim aTests : aTests = Array( _
"SELECT FieldName AS FieldNameAlias FROM table" _
, "SELECT [FieldName] AS [FieldNameAlias] FROM table" _
, "SELECT WhatEver.FieldName AS [FieldNameAlias] FROM table" _
, "SELECT F1 AS A1, F2 AS A2 FROM table" _
, "SELECT F1 AS [AS], F2 AS A2 FROM table" _
)
Dim oRE : Set oRE = New Regexp
oRE.Pattern = "\[?(\w+(?:\.\w+)*)\]?\s+AS\s+\[?(\w+)\]?"
oRE.Global = True
oRE.IgnoreCase = True
Dim sTest, oMTS, oMT
For Each sTest In aTests
WScript.Echo "------", sTest
Set oMTS = oRE.Execute( sTest )
For Each oMT In oMTS
WScript.Echo "", oMT.SubMatches( 1 ), "==>",
oMT.SubMatches( 0 ) Next
Next


Does this handle this case:
Select ([Field1] & [Field2]) AS FieldAlias

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


.



Relevant Pages

  • Re: How can i get the "true" name of an aliased field?
    ... Dim aTests: aTests = Array(_ ... Dim oRE: Set oRE = New Regexp ... Dim sTest, oMTS, oMT ...
    (microsoft.public.data.ado)
  • Re: Select Case Limitations
    ... Dim aTests: aTests = Array(_ ... Dim oRE: Set oRE = New RegExp ... For Each sTest In aTests ...
    (microsoft.public.scripting.vbscript)
  • Re: Find newest file in a series of folders
    ... I left the Greman date format because I don't know what to put in it's ... WScript.Echo oMTS.Count just before the IF and the oMTS count is always 0. ... Dim sTeam: sTeam = oFS.GetFileName ... Dim sTxt: sTxt = oExec.Stdout.ReadAll ...
    (microsoft.public.scripting.vbscript)
  • Re: Find newest file in a series of folders
    ... Dim sTeam: sTeam = oFS.GetFileName ... WScript.Echo "Starting in", sRoot, sTeam ... Dim sTxt: sTxt = oExec.Stdout.ReadAll ... Dim oMTS: Set oMTS = reFile.Execute ...
    (microsoft.public.scripting.vbscript)
  • Re: better way to enumerate subfolders by name
    ... Dim aTests(15) ... For nIdx = 0 To UBound(aTests) ... sPrfx = Left ...
    (microsoft.public.scripting.vbscript)