I make simple application for view main properties of selected database (using systables). I have to find relation between systables that lets me find property of each key, without using functions or procedures. For example this SQL code:
*******example1
SELECT dbo.sysobjects.name, dbo.sysindexes.name AS IndexName, dbo.syscolumns.name AS ComponentName, dbo.syscolumns.length,
dbo.systypes.name AS Type
FROM dbo.systypes RIGHT OUTER JOIN
dbo.syscolumns ON dbo.systypes.xusertype = dbo.syscolumns.xusertype RIGHT OUTER JOIN
dbo.sysindexkeys INNER JOIN
dbo.sysobjects ON dbo.sysindexkeys.id = dbo.sysobjects.id INNER JOIN
dbo.sysindexes ON dbo.sysindexkeys.indid = dbo.sysindexes.indid AND dbo.sysobjects.id = dbo.sysindexes.id ON
dbo.syscolumns.id = dbo.sysobjects.id AND dbo.syscolumns.colid = dbo.sysindexkeys.colid
WHERE (dbo.sysindexes.name NOT LIKE '_WA_%')
ORDER BY dbo.sysobjects.name, IndexName
*******
make view showing all keys components (columns that each key is made of). It works pretty good. But now I want find properties of each key (I mean is key ascending or descending). I can do it using simple function INDEXKEY_PROPERTY like that :
******example2
SELECT dbo.sysindexes.id, dbo.sysindexes.name AS Indexname, dbo.syscolumns.name AS Components, dbo.syscolumns.length,
dbo.systypes.name AS Type, (CASE WHEN INDEXKEY_PROPERTY(dbo.sysobjects.id, dbo.sysindexes.indid, dbo.sysindexkeys.keyno,
'IsDescending') = 0 THEN 'Ascending' ELSE 'Descending' END) AS SortProperty
FROM dbo.systypes RIGHT OUTER JOIN
dbo.syscolumns ON dbo.systypes.xusertype = dbo.syscolumns.xusertype RIGHT OUTER JOIN
dbo.sysindexkeys INNER JOIN
dbo.sysobjects ON dbo.sysindexkeys.id = dbo.sysobjects.id INNER JOIN
dbo.sysindexes ON dbo.sysindexkeys.indid = dbo.sysindexes.indid AND dbo.sysobjects.id = dbo.sysindexes.id ON
dbo.syscolumns.id = dbo.sysobjects.id AND dbo.syscolumns.colid = dbo.sysindexkeys.colid
WHERE (dbo.sysindexes.name NOT LIKE '_WA_%')
ORDER BY dbo.sysobjects.name, Indexname
*******
This is what I want but I have to do it without using function (like in exp.1) So I need to find good relation between some systables.
Please!!! Somebody help me!
Sorry about my english
I would like to know why you want to go in this route, as it is easy to manage the code with such functions in the release. Using system tables directly is not a good practice.|||I work in Clarion, so I don't want to use SQL code at all. I just need information where in system tables can I find this, and then I can use Clarion interface to connect with matching table and get all information I need.
I can use SQL code, but it's real hardcore in Clarion. I have been askin' before how to find all components of index/key without functions and everybody suggest, that I should use function, but it's not so easy. I founded, how to do it my way. Now the same problem with key properties. Where is it? If you know something about it please help.
No comments:
Post a Comment