Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sql server - vfp how?
Message
From
12/04/2012 08:20:33
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
11/04/2012 11:34:50
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01541027
Message ID:
01541187
Views:
45
>How can I create a table in SQL from VFP and populate it from a cursor?

You send a CREATE TABLE command and then a bunch of insert statements... in metacode
sqlexec(h, "create table mytable (field1 ..., ...)")
select mycursor
scan
   sqlexec(h, "insert into mytable (field1, field2, ...) values (?mycursor.field1, ?mycursor.field2, ...)")
endscan
If it's a temp table, then prefix it with # on SQL side and issue a "drop table #mytable" when you don't need it anymore.

Error handling, optimization (like not sending more than one statement per sqlexec()), and actual fields are left as en exercise to the reader :).

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform