日期:2014-05-17  浏览次数:20521 次

SQL语句报错求解
SQL code
DECLARE @TId TABLE(RowN int IDENTITY (1, 1) NOT NULL, Id uniqueidentifier) INSERT INTO @TId (Id) SELECT TOP 20 id FROM (SELECT a.KnowledgeItemId AS id , '4095' as RightValue , isnull(cc.IsSign,0) as IsSign, cc.CreatedOn as SignOn ,'' AS EntityIconPath, a.Title , b.Name AS CatalogId , a.CatalogId AS vf_CatalogId , a.Status , a.Status AS vf_Status , a.State , a.State AS vf_State , a.CreatedBy, a.CreatedBy AS vf_CreatedBy , a.CreatedOn , a.Period  FROM t_d_KnowledgeItem a LEFT JOIN t_d_KnowledgeCatalog b ON a.CatalogId=b.KnowledgeCatalogId   left join (select distinct KnowledgeItemId, CreatedOn, 1 as IsSign from Gax_Platform.dbo.t_d_KnowledgeSignItem where UserId='1') as cc on cc.KnowledgeItemId= a.KnowledgeItemId  WHERE  a.AmendmentKnowledgeId is null  IsSign=1  AND  a.State=1  ) TAAA  ORDER BY SignOn  DESC  SELECT COUNT(*) AS RecordCount FROM (SELECT a.KnowledgeItemId AS id , '4095' as RightValue , isnull(cc.IsSign,0) as IsSign, cc.CreatedOn as SignOn ,'' AS EntityIconPath, a.Title , b.Name AS CatalogId , a.CatalogId AS vf_CatalogId , a.Status , a.Status AS vf_Status , a.State , a.State AS vf_State , a.CreatedBy, a.CreatedBy AS vf_CreatedBy , a.CreatedOn , a.Period  FROM t_d_KnowledgeItem a LEFT JOIN t_d_KnowledgeCatalog b ON a.CatalogId=b.KnowledgeCatalogId   left join (select distinct KnowledgeItemId, CreatedOn, 1 as IsSign from Gax_Platform.dbo.t_d_KnowledgeSignItem where UserId='1') as cc on cc.KnowledgeItemId= a.KnowledgeItemId  WHERE  a.AmendmentKnowledgeId is null  IsSign=1  AND  a.State=1  ) TAAA IF EXISTS(SELECT * FROM @TId) SELECT * FROM (SELECT a.KnowledgeItemId AS id , '4095' as RightValue , isnull(cc.IsSign,0) as IsSign, cc.CreatedOn as SignOn ,'' AS EntityIconPath, a.Title , b.Name AS CatalogId , a.CatalogId AS vf_CatalogId , a.Status , a.Status AS vf_Status , a.State , a.State AS vf_State , a.CreatedBy, a.CreatedBy AS vf_CreatedBy , a.CreatedOn , a.Period  FROM t_d_KnowledgeItem a LEFT JOIN t_d_KnowledgeCatalog b ON a.CatalogId=b.KnowledgeCatalogId   left join (select distinct KnowledgeItemId, CreatedOn, 1 as IsSign from Gax_Platform.dbo.t_d_KnowledgeSignItem where UserId='1') as cc on cc.KnowledgeItemId= a.KnowledgeItemId  WHERE  a.AmendmentKnowledgeId is null  IsSign=1  AND  a.State=1  ) TAAA, @TId TId WHERE TId.RowN>=1 AND TId.RowN<=20 AND TId.Id=TAAA.id ORDER BY TId.RowN
Error description:第 1 行: 'IsSign' 附近有语法错误。
第 1 行: 'IsSign' 附近有语法错误。
第 1 行: 'IsSign' 附近有语法错误


------解决方案--------------------
WHERE a.AmendmentKnowledgeId is null IsSign=1 AND a.State=1)
这里有问题吧,少一个and

你这个太长了