Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default field alias when running SQL on sheet ranges

Is it possible to the header fields when running SQL on sheet ranges?
The connection is like this:

strSheetConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & ActiveWorkbook.FullName & ";" & _
"Extended Properties=Excel 8.0;"

Set rs = New ADODB.Recordset

rs.Open Source:=strQuery, _
ActiveConnection:=strSheetConn, _
CursorType:=adOpenForwardOnly, _
LockType:=adLockReadOnly, _
Options:=adCmdText

Tried all sorts of constructions, but nil worked sofar.

Also, would it be possible to run SQL on sheet ranges without saving the
workbook first?
I suppose not as SQL always runs on disk (files) structures rather than data
in memory.

RBS

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default field alias when running SQL on sheet ranges

To what the header fields? Do you mean see them? If so, the recordset has a
Fields collection property that you can iterate through.

On the second point, you are correct, it has to be saved.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"RB Smissaert" wrote in message
...
Is it possible to the header fields when running SQL on sheet ranges?
The connection is like this:

strSheetConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & ActiveWorkbook.FullName & ";" & _
"Extended Properties=Excel 8.0;"

Set rs = New ADODB.Recordset

rs.Open Source:=strQuery, _
ActiveConnection:=strSheetConn, _
CursorType:=adOpenForwardOnly, _
LockType:=adLockReadOnly, _
Options:=adCmdText

Tried all sorts of constructions, but nil worked sofar.

Also, would it be possible to run SQL on sheet ranges without saving the
workbook first?
I suppose not as SQL always runs on disk (files) structures rather than

data
in memory.

RBS



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default field alias when running SQL on sheet ranges

What I mean is this:
In normal SQL you can do:

SELECT
E.TERM_TEXT FIELDALIAS
FROM
ENTRY E
WHERE
E.READ_CODE = 'G25..'

This means you will get FIELDALIAS in your output header, rather than
TERM_TEXT.

How would you do the same in range SQL?
You could of course loop through the fields in the recordset and replace the
fields names in the sheet output, but it would be easier if you could do it
in SQL.

RBS

"Bob Phillips" wrote in message
...
To what the header fields? Do you mean see them? If so, the recordset has
a
Fields collection property that you can iterate through.

On the second point, you are correct, it has to be saved.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"RB Smissaert" wrote in message
...
Is it possible to the header fields when running SQL on sheet ranges?
The connection is like this:

strSheetConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & ActiveWorkbook.FullName & ";" & _
"Extended Properties=Excel 8.0;"

Set rs = New ADODB.Recordset

rs.Open Source:=strQuery, _
ActiveConnection:=strSheetConn, _
CursorType:=adOpenForwardOnly, _
LockType:=adLockReadOnly, _
Options:=adCmdText

Tried all sorts of constructions, but nil worked sofar.

Also, would it be possible to run SQL on sheet ranges without saving the
workbook first?
I suppose not as SQL always runs on disk (files) structures rather than

data
in memory.

RBS




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default field alias when running SQL on sheet ranges

Oky, I understand.

Use the As operator

SELECT
E.TERM_TEXT AS FIELDALIAS
FROM
ENTRY E
WHERE
E.READ_CODE = 'G25..'


--

HTH

RP
(remove nothere from the email address if mailing direct)


"RB Smissaert" wrote in message
...
What I mean is this:
In normal SQL you can do:

SELECT
E.TERM_TEXT FIELDALIAS
FROM
ENTRY E
WHERE
E.READ_CODE = 'G25..'

This means you will get FIELDALIAS in your output header, rather than
TERM_TEXT.

How would you do the same in range SQL?
You could of course loop through the fields in the recordset and replace

the
fields names in the sheet output, but it would be easier if you could do

it
in SQL.

RBS

"Bob Phillips" wrote in message
...
To what the header fields? Do you mean see them? If so, the recordset

has
a
Fields collection property that you can iterate through.

On the second point, you are correct, it has to be saved.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"RB Smissaert" wrote in message
...
Is it possible to the header fields when running SQL on sheet ranges?
The connection is like this:

strSheetConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & ActiveWorkbook.FullName & ";" & _
"Extended Properties=Excel 8.0;"

Set rs = New ADODB.Recordset

rs.Open Source:=strQuery, _
ActiveConnection:=strSheetConn, _
CursorType:=adOpenForwardOnly, _
LockType:=adLockReadOnly, _
Options:=adCmdText

Tried all sorts of constructions, but nil worked sofar.

Also, would it be possible to run SQL on sheet ranges without saving

the
workbook first?
I suppose not as SQL always runs on disk (files) structures rather than

data
in memory.

RBS






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default field alias when running SQL on sheet ranges

Thanks Bob, that is the one I forgot about.
Works nicely even with Interbase.

RBS


"Bob Phillips" wrote in message
...
Oky, I understand.

Use the As operator

SELECT
E.TERM_TEXT AS FIELDALIAS
FROM
ENTRY E
WHERE
E.READ_CODE = 'G25..'


--

HTH

RP
(remove nothere from the email address if mailing direct)


"RB Smissaert" wrote in message
...
What I mean is this:
In normal SQL you can do:

SELECT
E.TERM_TEXT FIELDALIAS
FROM
ENTRY E
WHERE
E.READ_CODE = 'G25..'

This means you will get FIELDALIAS in your output header, rather than
TERM_TEXT.

How would you do the same in range SQL?
You could of course loop through the fields in the recordset and replace

the
fields names in the sheet output, but it would be easier if you could do

it
in SQL.

RBS

"Bob Phillips" wrote in message
...
To what the header fields? Do you mean see them? If so, the recordset

has
a
Fields collection property that you can iterate through.

On the second point, you are correct, it has to be saved.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"RB Smissaert" wrote in message
...
Is it possible to the header fields when running SQL on sheet ranges?
The connection is like this:

strSheetConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & ActiveWorkbook.FullName & ";" & _
"Extended Properties=Excel 8.0;"

Set rs = New ADODB.Recordset

rs.Open Source:=strQuery, _
ActiveConnection:=strSheetConn, _
CursorType:=adOpenForwardOnly, _
LockType:=adLockReadOnly, _
Options:=adCmdText

Tried all sorts of constructions, but nil worked sofar.

Also, would it be possible to run SQL on sheet ranges without saving

the
workbook first?
I suppose not as SQL always runs on disk (files) structures rather
than
data
in memory.

RBS









Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pivot Tables- SQL Alias' & Field Lists Marcotte A Excel Worksheet Functions 1 February 19th 10 05:24 PM
Creating a Calculated Field From a Running Total Field Joe Excel Worksheet Functions 3 September 5th 08 02:09 AM
Pivot Table, Calculated Field, Running Total Valeri Excel Worksheet Functions 0 July 17th 08 06:29 PM
running total from the same field on multiple sheets as i add she obviscator Excel Worksheet Functions 2 April 15th 06 06:34 PM
Shadows of the Pivottable Field List while macro is running David P Excel Worksheet Functions 0 February 25th 05 07:11 PM


All times are GMT +1. The time now is 04:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"