Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default SQL "INSERT INTO" puts Single Quote in Front of Text Value

I am using MS Excel 2002 to manage financial data.

To add new data to a named range in a spreadsheet, I have
written a query that uses the SQL "INSERT INTO" capability.

Works well, except for two problems. For this Post, the
problem I'm trying to solve is that the update query
inserts a single quote at the front of each text field.
E.g., the field "Symbol" could have the value of "IBM" (my
double quotes for purposes of explanation). But, the
update query produces "'IBM".

Any suggestions on how I can get the query to drop the
spurious single quote?

Thanks,
David
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default SQL "INSERT INTO" puts Single Quote in Front of Text Value

Use ADO Parameters.
Or if that's not an option, then try single-quote twice (eg. "''IBM")


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"David Weilmuenster" wrote in message
...
I am using MS Excel 2002 to manage financial data.

To add new data to a named range in a spreadsheet, I have
written a query that uses the SQL "INSERT INTO" capability.

Works well, except for two problems. For this Post, the
problem I'm trying to solve is that the update query
inserts a single quote at the front of each text field.
E.g., the field "Symbol" could have the value of "IBM" (my
double quotes for purposes of explanation). But, the
update query produces "'IBM".

Any suggestions on how I can get the query to drop the
spurious single quote?

Thanks,
David



  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default SQL "INSERT INTO" puts Single Quote in Front of Text Value

Rob, thanks. ADO isn't an option in this case.

But, I'm puzzled by your second suggestion. I'm trying to
eliminate the leading single quote from the result, not
preserve it.

Admittedly, I'm new to SQL/Excel, so I may have
misunderstood the hint.

David

-----Original Message-----
Use ADO Parameters.
Or if that's not an option, then try single-quote twice

(eg. "''IBM")


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"David Weilmuenster"

wrote in message
...
I am using MS Excel 2002 to manage financial data.

To add new data to a named range in a spreadsheet, I

have
written a query that uses the SQL "INSERT INTO"

capability.

Works well, except for two problems. For this Post, the
problem I'm trying to solve is that the update query
inserts a single quote at the front of each text field.
E.g., the field "Symbol" could have the value of "IBM"

(my
double quotes for purposes of explanation). But, the
update query produces "'IBM".

Any suggestions on how I can get the query to drop the
spurious single quote?

Thanks,
David



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default SQL "INSERT INTO" puts Single Quote in Front of Text Value

sorry. I thought you were trying to preserve it. My mistake.

I'm not certain how a single quote is being introduced.
Could I see your update SQL?

--
Rob van Gelder - http://www.vangelder.co.nz/excel


wrote in message
...
Rob, thanks. ADO isn't an option in this case.

But, I'm puzzled by your second suggestion. I'm trying to
eliminate the leading single quote from the result, not
preserve it.

Admittedly, I'm new to SQL/Excel, so I may have
misunderstood the hint.

David

-----Original Message-----
Use ADO Parameters.
Or if that's not an option, then try single-quote twice

(eg. "''IBM")


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"David Weilmuenster"

wrote in message
...
I am using MS Excel 2002 to manage financial data.

To add new data to a named range in a spreadsheet, I

have
written a query that uses the SQL "INSERT INTO"

capability.

Works well, except for two problems. For this Post, the
problem I'm trying to solve is that the update query
inserts a single quote at the front of each text field.
E.g., the field "Symbol" could have the value of "IBM"

(my
double quotes for purposes of explanation). But, the
update query produces "'IBM".

Any suggestions on how I can get the query to drop the
spurious single quote?

Thanks,
David



.



  #5   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default SQL "INSERT INTO" puts Single Quote in Front of Text Value

Thanks, Rob. The update SQL is below. The single quote
is being introduced as the lead character in [Symbol].

I just recognized, however, that the quote may not
actually be part of the field value, although it is
visible when one looks at the Excel cell. Comparisons,
searches, etc., on [Symbol] in Excel seem to ignore the
single quote, and if that's true, its presence poses no
problem for my spreadsheet.

Thanks again,
David
---------------------------

DBQ=D:\My Documents\Personal\Investment\General\Metastock
Scans\Boucher New Highs - New Lows.xls;DefaultDir=D:\My
Documents\Personal\Investment\General\Metastock
Scans;Driver={Microsoft Excel Driver
(*.xls)};DriverId=790;FIL=excel
8.0;MaxBufferSize=2048;MaxScanRows=8;PageTimeout=5 ;ReadOnly
=0;SafeTransactions=0;Threads=3;UserCommitSync=Yes ;
INSERT INTO Master_Database ([COMPANY NAME], [Eqy Industry
Sector], [Eqy Industry Group], [Eqy Industry Subgroup],
[HiLo], [Date], [Symbol]) SELECT
`Today$Boucher_New_Highs`.`COMPANY NAME`,
`Today$Boucher_New_Highs`.`Eqy Industry Sector`,
`Today$Boucher_New_Highs`.`Eqy Industry Group`,
`Today$Boucher_New_Highs`.`Eqy Industry Subgroup`, '1' ,
Date() , trim(`Today$Boucher_New_Highs`.Symbol) FROM
`Today$Boucher_New_Highs` `Today$Boucher_New_Highs`



-----Original Message-----
sorry. I thought you were trying to preserve it. My

mistake.

I'm not certain how a single quote is being introduced.
Could I see your update SQL?

--
Rob van Gelder - http://www.vangelder.co.nz/excel


wrote in message
...
Rob, thanks. ADO isn't an option in this case.

But, I'm puzzled by your second suggestion. I'm trying

to
eliminate the leading single quote from the result, not
preserve it.

Admittedly, I'm new to SQL/Excel, so I may have
misunderstood the hint.

David

-----Original Message-----
Use ADO Parameters.
Or if that's not an option, then try single-quote twice

(eg. "''IBM")


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"David Weilmuenster"

wrote in message
...
I am using MS Excel 2002 to manage financial data.

To add new data to a named range in a spreadsheet, I

have
written a query that uses the SQL "INSERT INTO"

capability.

Works well, except for two problems. For this Post,

the
problem I'm trying to solve is that the update query
inserts a single quote at the front of each text

field.
E.g., the field "Symbol" could have the value

of "IBM"
(my
double quotes for purposes of explanation). But, the
update query produces "'IBM".

Any suggestions on how I can get the query to drop

the
spurious single quote?

Thanks,
David


.



.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default SQL "INSERT INTO" puts Single Quote in Front of Text Value

Hi David,

Is it possible that the cell containing the symbol has a single quote at the
beginning of it? Maybe to keep smart tags from bothering you? I wasn't
aware that they would get transferred over via data access, but maybe so.
If that's the case, you can try using the RIGHT and LEN functions to correct
it:

trim(`Today$Boucher_New_Highs`.Symbol)

becomes:

RIGHT(Today$Boucher_New_Highs`.Symbol,
LEN(Today$Boucher_New_Highs`.Symbol)-1)

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


wrote:
Thanks, Rob. The update SQL is below. The single quote
is being introduced as the lead character in [Symbol].

I just recognized, however, that the quote may not
actually be part of the field value, although it is
visible when one looks at the Excel cell. Comparisons,
searches, etc., on [Symbol] in Excel seem to ignore the
single quote, and if that's true, its presence poses no
problem for my spreadsheet.

Thanks again,
David
---------------------------

DBQ=D:\My Documents\Personal\Investment\General\Metastock
Scans\Boucher New Highs - New Lows.xls;DefaultDir=D:\My
Documents\Personal\Investment\General\Metastock
Scans;Driver={Microsoft Excel Driver
(*.xls)};DriverId=790;FIL=excel
8.0;MaxBufferSize=2048;MaxScanRows=8;PageTimeout=5 ;ReadOnly
=0;SafeTransactions=0;Threads=3;UserCommitSync=Yes ;
INSERT INTO Master_Database ([COMPANY NAME], [Eqy Industry
Sector], [Eqy Industry Group], [Eqy Industry Subgroup],
[HiLo], [Date], [Symbol]) SELECT
`Today$Boucher_New_Highs`.`COMPANY NAME`,
`Today$Boucher_New_Highs`.`Eqy Industry Sector`,
`Today$Boucher_New_Highs`.`Eqy Industry Group`,
`Today$Boucher_New_Highs`.`Eqy Industry Subgroup`, '1' ,
Date() , trim(`Today$Boucher_New_Highs`.Symbol) FROM
`Today$Boucher_New_Highs` `Today$Boucher_New_Highs`



-----Original Message-----
sorry. I thought you were trying to preserve it. My mistake.

I'm not certain how a single quote is being introduced.
Could I see your update SQL?

--
Rob van Gelder -
http://www.vangelder.co.nz/excel


wrote in message
...
Rob, thanks. ADO isn't an option in this case.

But, I'm puzzled by your second suggestion. I'm trying to
eliminate the leading single quote from the result, not
preserve it.

Admittedly, I'm new to SQL/Excel, so I may have
misunderstood the hint.

David

-----Original Message-----
Use ADO Parameters.
Or if that's not an option, then try single-quote twice (eg.
"''IBM")


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"David Weilmuenster"
wrote in message
...
I am using MS Excel 2002 to manage financial data.

To add new data to a named range in a spreadsheet, I have
written a query that uses the SQL "INSERT INTO" capability.

Works well, except for two problems. For this Post, the
problem I'm trying to solve is that the update query
inserts a single quote at the front of each text field.
E.g., the field "Symbol" could have the value of "IBM" (my
double quotes for purposes of explanation). But, the
update query produces "'IBM".

Any suggestions on how I can get the query to drop the
spurious single quote?

Thanks,
David


.



.


  #7   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default SQL "INSERT INTO" puts Single Quote in Front of Text Value

Jake, thanks again.

I checked the source file (just a plain old text file
exported from another program), and there is no single
quote in that field.

However, and luckily, it turns out that the quote presents
no problem even if it remains in my Excel data. It may
just be some sort of data qualifier/delimiter that has no
effect on the cell value. I can search, sort, compare,
etc. and the single quote has no effect.

On to the next one...

David

-----Original Message-----
Hi David,

Is it possible that the cell containing the symbol has a

single quote at the
beginning of it? Maybe to keep smart tags from bothering

you? I wasn't
aware that they would get transferred over via data

access, but maybe so.
If that's the case, you can try using the RIGHT and LEN

functions to correct
it:

trim(`Today$Boucher_New_Highs`.Symbol)

becomes:

RIGHT(Today$Boucher_New_Highs`.Symbol,
LEN(Today$Boucher_New_Highs`.Symbol)-1)

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address

unmonitored]


wrote:
Thanks, Rob. The update SQL is below. The single quote
is being introduced as the lead character in [Symbol].

I just recognized, however, that the quote may not
actually be part of the field value, although it is
visible when one looks at the Excel cell. Comparisons,
searches, etc., on [Symbol] in Excel seem to ignore the
single quote, and if that's true, its presence poses no
problem for my spreadsheet.

Thanks again,
David
---------------------------

DBQ=D:\My

Documents\Personal\Investment\General\Metastock
Scans\Boucher New Highs - New Lows.xls;DefaultDir=D:\My
Documents\Personal\Investment\General\Metastock
Scans;Driver={Microsoft Excel Driver
(*.xls)};DriverId=790;FIL=excel

8.0;MaxBufferSize=2048;MaxScanRows=8;PageTimeout=5 ;ReadOnly
=0;SafeTransactions=0;Threads=3;UserCommitSync=Yes ;
INSERT INTO Master_Database ([COMPANY NAME], [Eqy

Industry
Sector], [Eqy Industry Group], [Eqy Industry Subgroup],
[HiLo], [Date], [Symbol]) SELECT
`Today$Boucher_New_Highs`.`COMPANY NAME`,
`Today$Boucher_New_Highs`.`Eqy Industry Sector`,
`Today$Boucher_New_Highs`.`Eqy Industry Group`,
`Today$Boucher_New_Highs`.`Eqy Industry Subgroup`, '1' ,
Date() , trim(`Today$Boucher_New_Highs`.Symbol) FROM
`Today$Boucher_New_Highs` `Today$Boucher_New_Highs`



-----Original Message-----
sorry. I thought you were trying to preserve it. My

mistake.

I'm not certain how a single quote is being introduced.
Could I see your update SQL?

--
Rob van Gelder - http://www.vangelder.co.nz/excel


wrote in message
...
Rob, thanks. ADO isn't an option in this case.

But, I'm puzzled by your second suggestion. I'm

trying to
eliminate the leading single quote from the result,

not
preserve it.

Admittedly, I'm new to SQL/Excel, so I may have
misunderstood the hint.

David

-----Original Message-----
Use ADO Parameters.
Or if that's not an option, then try single-quote

twice (eg.
"''IBM")


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"David Weilmuenster"
wrote in message
...
I am using MS Excel 2002 to manage financial data.

To add new data to a named range in a spreadsheet,

I have
written a query that uses the SQL "INSERT INTO"

capability.

Works well, except for two problems. For this

Post, the
problem I'm trying to solve is that the update query
inserts a single quote at the front of each text

field.
E.g., the field "Symbol" could have the value

of "IBM" (my
double quotes for purposes of explanation). But,

the
update query produces "'IBM".

Any suggestions on how I can get the query to drop

the
spurious single quote?

Thanks,
David


.



.


.

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
Multiple "source" workbooks linked to single "destination" workboo DAVEJAY Excel Worksheet Functions 1 September 17th 07 05:33 PM
Lost "File Menu" - now it's "Edit / View / Insert.." but no "F daves Excel Discussion (Misc queries) 3 April 24th 07 04:52 AM
Change data in a single column from "last, first" to "first last" Jeanne Excel Discussion (Misc queries) 2 March 27th 06 08:40 PM
Insert "-" in text "1234567890" to have a output like this"123-456-7890" Alwyn Excel Discussion (Misc queries) 3 October 25th 05 11:36 PM
Macro to insert "0" in front of 4 character string Lowell B. Copeland[_2_] Excel Programming 2 August 29th 03 03:43 PM


All times are GMT +1. The time now is 10:52 PM.

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

About Us

"It's about Microsoft Excel"