Board index » delphi » Retrieving default field values from MSSQL table

Retrieving default field values from MSSQL table

I need to retrieve the default value for a field in a table in a MSSQL database.

I have tried using the BDE's DbiGetVchkDesc function. In the resulting VCHKDesc structure I assemble a string from the aDefVal array. Instead of the actual value I get a string (eg DF__READER_READ_08246310). If I let MS Enterprise Manager generate a SQL script for the Database definition I see this string, and the accompanying default value.

This is all fine, however in my application I can't get to this default value.

Any ideas?

Thanks
Hedley

 

Re:Retrieving default field values from MSSQL table


Hedley,
    There are a couple of ways to do this. One is to execute a query on the
database (I don't know the exact query but there is a 'default constraint'
for every default column value) The other way is to go through the SQL DMO
COM object that is installed with SQL Server (sqldmo.dll) - I have created a
fairly nice wrapper (complete with access to default values) around this
object if you want it. (although it was written for SQL 2000, you may need
to make a few minor changes for SQL 7)

Quote
"Hedley" <hed...@ise.co.za> wrote in message news:3b8bb7cf$1_1@dnews...

> I need to retrieve the default value for a field in a table in a MSSQL
database.

> I have tried using the BDE's DbiGetVchkDesc function. In the resulting

VCHKDesc structure I assemble a string from the aDefVal array. Instead of
the actual value I get a string (eg DF__READER_READ_08246310). If I let MS
Enterprise Manager generate a SQL script for the Database definition I see
this string, and the accompanying default value.
Quote

> This is all fine, however in my application I can't get to this default
value.

> Any ideas?

> Thanks
> Hedley

Other Threads