Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
BCP from Foxpro
Message
From
13/01/2008 20:32:58
Suhas Hegde
Dental Surgeon
Sirsi, India
 
 
To
12/01/2008 17:43:17
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Environment versions
Visual FoxPro:
VFP 6 SP5
Database:
MS SQL Server
Miscellaneous
Thread ID:
01281359
Message ID:
01281514
Views:
11
CLOSE tables
clear
m.fstr = conver_to_hex(FILETOSTR(GETFILE()))
m.pstr = putfile()
han = SQLCONNECT('A')
m.lcsql = [CREATE TABLE ##foo1 (f1 Varbinary(max) )]
SQLEXEC(han,m.lcsql)

lcsql = [insert into ##foo1 (f1) values ( ]+m.fstr+[)]
SQLEXEC(han,lcsql)
	lcsql = [DECLARE @SQLcommand varchar(1000) ]+;
	[set @SQLcommand = 'bcp "SELECT f1 FROM ##foo1 " queryout "]+pstr+[" -f"c:\test\image.fmt" -T  -SNAGAVENI\SQLEXPRESS ' ]+;
	[exec xp_cmdshell @SQLcommand]
SQLEXEC(han,lcsql)  

SQLDISCONNECT(han)

procedure conver_to_hex
LPARAMETERS tcstring
LOCAL lcstring
lcstring = '0x'
FOR m.xi = 1 TO LEN(tcstring)
lcstring = lcstring + strtran(TRANSFORM(ASC(SUBSTR(tcstring,m.xi,1)) ,'@0'),'0x000000','')
endfor
RETURN lcstring
And a image.fmt is

9.0
1
1 SQLBINARY 0 0 "" 1 f1 ""


Please Note it is tabs in between like

1 tab SQLBINARY tab 0 tab 0 tab "" tab 1 tab f1 tab ""


I had spaces and that kinda put me off for a very very long time.

Suhashegde
Previous
Reply
Map
View

Click here to load this message in the networking platform