Discussion:
Index Fields Using TSQLQuery and MS SQL Server 2000
(too old to reply)
Eduardo Jauch
2008-03-16 11:48:09 UTC
Permalink
Hi,

How can I find if a specific field in a TSQLQuery is an Index field?

I'm using something like this:

with FSQLQuery do
begin
for i := 0 to FieldList.Count - 1 do
begin
info := TMyDBFieldInfo.Create;

info.FieldName := FieldList[i].FieldName;
info.FieldKey := ????

FFieldList.Add(info);
end;
end;

Where to find the definition if the field is an Index field on the
SQLServer table?

Thanks!
Rich Werning
2008-03-17 18:29:18 UTC
Permalink
Post by Eduardo Jauch
Hi,
How can I find if a specific field in a TSQLQuery is an Index field?
[...]
Where to find the definition if the field is an Index field on the
SQLServer table?
With Delphi 2007? You can use a MetaData request on TSqlDataset:

function GetTableIndexColumns(aConnection: TSQLConnection; value: string) :
OleVariant;
begin
ADataSet:= TSQLDataSet.Create(nil);
try
ADataSet.SqlConnection := aConnection;
ADataSet.DbxCommandType := TDBXCommandTypes.DbxMetaData;
ADataSet.CommandText := 'GetIndexColumns ' + aSchema + '.' + Value;
ADataSet.Open;
// Do something with the indexes
Finally
ADataset.Free;
end;
end;

Hope this helps,
--
Rich Werning
TIP Technologies, Inc.
Eduardo Jauch
2008-03-18 16:21:22 UTC
Permalink
I was thinking much 'plain'...

This will help for shure [:)]

Thanks!

Loading...