Hai To EveryOne,
I wrote query to display all fields in particular screen. Iam getting screen name as input.This is the query
SELECT T2.[Name] AS 'TableName' , T1.[Name] AS 'Name', T0.[AliasID] AS 'Title', T0.[Descr] AS 'Description', T0.[EditSize] AS 'Edit Size', T0.[EditType] AS 'Edit Type', T0.[FieldID] AS 'Field'
FROM [dbo].[CUFD] T0 , [dbo].[OUDO] T1 ,
(Select A.[Name],substring(A.[Name],2,len(A.[Name])) as tbl from [dbo].[sysobjects] A Where name like '@%') T2
WHERE T0.[TableID] like '@PUR%' and
T2.[tbl] IN (Select OUDO.[tablename] as tbl from OUDO UNION ALL Select UDO1.[tablename] as tbl from UDO1)
and T2.[tbl]=T1.[TableName]
and T2.[Name]=T0.[TableID]
order by T1.[Name] asc,T2.[Name] desc
In this @pur% is the table name.
Now my problem is if i execute this query only head table is displayed not the detail table i also need detail table.
Does anyone tell me whts the wrong in this query....
Regards,
Anitha
Hi Anitha,
Try and simplify the query a bit. I have modified your query to the query below. I hope it serves the same purpose.
SELECT T0.[TableID] AS 'TableName', T1.[Name] AS 'ObjectName', T0.[AliasID] AS 'Title', T0.[Descr] AS 'Description', T0.[EditSize] AS 'Edit Size', T0.[EditType] AS 'Edit Type', T0.[FieldID] AS 'Field' FROM [dbo].[CUFD] T0 LEFT OUTER JOIN OUDO T1 on T1.TableName = substring(T0.TableID, 2, Len(T0.TableID)-1) WHERE T0.[TableID] like '@PUR%'
Hope it helps,
Adele
Hi Anitha,
Your "and T2.[tbl]=T1.[TableName]" condition do this because there is only head table of user-defined object at T1 table (OUDO) not the detail table.
Try to delete this condition as below:
SELECT T2.[Name] AS 'TableName' , T1.[Name] AS 'Name', T0.[AliasID] AS 'Title', T0.[Descr] AS 'Description', T0.[EditSize] AS 'Edit Size', T0.[EditType] AS 'Edit Type', T0.[FieldID] AS 'Field'
FROM [dbo].[CUFD] T0 , [dbo].[OUDO] T1 ,
(Select A.[Name],substring(A.[Name],2,len(A.[Name])) as tbl from [dbo].[sysobjects] A Where name like '@%') T2
WHERE T0.[TableID] like '@PUR%' and
T2.[tbl] IN (Select OUDO.[tablename] as tbl from OUDO UNION ALL Select UDO1.[tablename] as tbl from UDO1)
and T2.[Name]=T0.[TableID]
order by T1.[Name] asc,T2.[Name] desc
This working fine on my side.
HIH,
Anton
Add a comment