#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Want to format data

I have data in Excel that is in 2 columns as below

Coloum 1 Coloum2
000199 CAON00000013
000200 CAON00000011


I wanted to create my SQL script from these columns as below

Update apdoc set user1 = 'Coloum2 value' where refnbr = 'Colum1 value'

As I have thousands of lines I have tried concatenate etc but it does not
come out ok as the ' don't come out ok and then leading 000 disappear in the
concatenate.

I would really appreciate some help on this.

Thanks

Sam




  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 427
Default Want to format data

Is this an Excel question or an SQL question? Your post says you have
the data in Excel and that SQL is dropping the lead apostrophe and
leading zeros. I know nothing about SQL, but can you declare the
variable in SQL as text so it will read those values as text?

As a workaround, if you write a VBA script that writes the data out of
Excel and into a text file, can you import the text file into SQL? The
VBA would look like

sub WriteToTextFile()
dim OutputString as string

open "c:\abc.txt" for output as #1 'write to a file called abc.txt on
your C: drive

range("a1").select 'change this cell reference to the upper left
corner of your data

do until activecell.value = "" 'perform loop functions until encounter
a blank row
outputstring = activecell.value & activecell.offset(0,1).value
print #1, outputstring
outputstring = ""
activecell.offset(1,0).select
loop

close #1
end sub

Dave O
Eschew Obfuscation
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
Lock Cell Format - Allow copy and paste of data without format change Chris12InKC Excel Worksheet Functions 2 May 9th 23 07:42 PM
change the display data format cell already contain data as date Harun Excel Discussion (Misc queries) 2 March 1st 10 11:48 AM
Increase Your Business By Data Conversion, Data Format and Data EntryServices in India Data Entry India Excel Worksheet Functions 1 March 31st 08 12:51 PM
Data Entry Online, Data Format, Data Conversion and Data EntryServices through Data Entry Outsourcing [email protected] Excel Discussion (Misc queries) 0 March 20th 08 12:45 PM
External Data Queries - Data Range Properties v Spreadsheet Format HLS Excel Discussion (Misc queries) 0 April 5th 06 11:09 AM


All times are GMT +1. The time now is 03:11 AM.

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"