Search code examples
databasesybasesap-ase

Sybase SQL Query Clarification


I have a sybase sql query and its returning an integer as the result.

Can anyone explain the logic of this query.

select b.length 
from sysobjects a, syscolumns b
where a.name = 'StuComm' 
and a.id = b.id and b.name = 'StuCD'

Solution

  • I'm kinda unsure what you are asking here, but I'll take a stab at it.

    This query is finding the length of the StuCD column in the StuComm table. It's pulling the information from sysobjects and syscolumns

    length is a column in syscolumns of type int, which is why you get an integer result. The length is the value that the datatype is declared with, so a column with declared as a varchar(255) will have a length of 255.