Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
BCP from Foxpro
Message
From
12/01/2008 17:43:17
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
12/01/2008 13:46:03
Suhas Hegde
Dental Surgeon
Sirsi, India
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:
01281377
Views:
9
>hi,
>
>Sql server 2005 express
>
>I can upload the image and want to copy it out from Sql server
>This works and a file is created. But the problem is that the BCp prefixes 4 bytes(Dword) the size of the file in BYtes. Hence the File is not readable format.
>
>How can i tell the BCP utility not to prefix the Dword value
>
>
>CLOSE tables
>clear
>m.fstr = conver_to_hex(FILETOSTR(GETFILE()))
>m.pstr = putfile()
>
>han = SQLCONNECT('A') && valid Sql connection
>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 "]+m.pstr+[" -T -N  -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
>
>
>
>
>Thanx in Advance
>
>Suhashegde

Suhas,
Do you need bcp for it? Check if this helps:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=182900&SiteID=1

Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform