Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Accessing SQL servers tables and fields
Message
From
28/05/2004 17:14:11
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00908326
Message ID:
00908337
Views:
24
>Is there a way in VFP8 to connect to SQL Server 2000 and get access to the Tables collection and then the Fields Collection of a specfic database. I need a way to extract and update all date fields in my SQL database and make the date NULL where the date is currently '12/30/1899'
>
>Any ideas are appreciated ?
h=sqlconnect(...)
sqlexec(h, "use {your database here}")
cTable='{your table here}'
sqlexec(h, "sp_columns ?cTable", "curColumns")
select * from curColumns where data_type=11;
   into curs curDateTimes

ldt={^1899/12/30}
scan
  cField=alltrim(column_name)
  sqlexec(h, "update ?cTable set "+cField+"=null where "+cField+"=?ldt")
endscan
sqldisconnect(h)
You may put another loop around this to extract table names first (call sp_tables), so to loop through all of your tables. You'll also need some checking to see whether you have any datetime fields at all, what was the result code from each of your sqlexec()s etc etc. This is just the bare bones approach.

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