Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Determining primary key in SQL Server
Message
From
28/12/2000 14:11:23
 
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00457474
Message ID:
00457497
Views:
30
>I've been using the sp_helpindex() in SQL server to return a cursor to VFP. I then pull out the index name and expression from the row marked with 'primary key' in the index_description.
>
>I found a problem using ODBC. When I use this code:
>?sqlexec(h,"{call sp_helpindex('SpecLink')}", 'csrIDX1')
>
>The index_keys field is returned as a C(30) and any index expressions longer than that have a chr(0) in the 30th character.
>
>This does not show up in query ananlyzer, only with ODBC. I'm using SQL Server 7.0 with SP2 and windows 2000 professional. ODBC driver is 3.70.08.21.
>
>None of the ODBC driver settings seem to have any affect.
>
>Help! I need a fix or another way to get the primary key name and expression.
>
>Thanks,
>Mike

If the client machine has SQL installed, you can use SQLDMO for this:

oSQL = CREATEOBJECT("SQLDMO.SQLServer")
oSQL.IntegratedSecurity = .T.
oSQL.LoginSecure = .T.
oSQL.Connect("MYSQLSERVER")
oTable = oSQL.Databases("MyDataBase").Tables("MyTable")
FOR EACH oColumn IN oTable.Columns
?oColumn.InPrimaryKey
ENDFOR
Erik Moore
Clientelligence
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform