Getting Table Schema

From: Mac Davis (newsgroups_at_blindsided.org)
Date: 03/27/05


Date: Sat, 26 Mar 2005 22:04:03 -0500

Two quick questions -
1) The Datatype ftString return a length on e greater than the field size
in SQL server. Is that because it is returning the size of the string
rather than the size of the field?

2) The following snippet is triggered by clicking on a table name in a list
box. It works fine with five of the seven tables. However, on the other
two tables,
the line FieldSize := adoquery1.Fields[i].DataSize; causes an error (List
Index out of bounds) only on the last field. The last field type is
SQLServer nvarchar.

if I comment out that line, then the fieldtype and fieldname are properly
reported.
Or
If I change the first line to FieldCount-2 then there is no error.

Any suggestions or explanation would be appreciated.

for i:= 0 to qry.FieldCount - 1 do begin
      stName := qry.Fields [i].FieldName;
      dt := qry.Fields[i].DataType;
      FieldSize := adoquery1.Fields[i].DataSize;

      stName := PadString (12,stName);
      stType := Field_Type (dt);

      if dt = ftString
         then stSize := inttostr(Fieldsize - 1)
         else stSize := inttostr(FieldSize);

      stSize := Padsize (2,stSize);

      listbox1.items.add (stName + ' - ' + stSize +'...'+ stType);

    end;

-dmd-
If the obvious weren't so obscure, I'd be less confused.



Relevant Pages

  • Re: using modify table command
    ... Am new to sql server to sobear with me, have checked around but cant ... I want to change fieldname from nvarcharto nvarcharas part ... ALTER TABLE myTable ALTER COLUMN fieldname nvarchar ...
    (comp.databases.ms-sqlserver)
  • Re: Each GROUP BY expression must contain at least one column that is not an outer reference
    ... Which is @FieldName in the select statement. ... where the string expression is ... Maybe you like to believe that SQL Server will guess that it should ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: NULL Changed to Empty String
    ... NULL field values changed to empty strings, ... longer selectable with 'WHERE FieldName IS NULL', ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (microsoft.public.sqlserver.programming)
  • Access APD question.
    ... If you sent a view from SQL server 2005 to Access, ... something like SELECT * FROM vwNAME WHERE FieldName = SomeFilter. ... you SQL server transfer the whole view or would it transfer just the ...
    (comp.databases.ms-access)