Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 error in query

Author  Topic 

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2008-02-06 : 01:38:05
Dear All,
i'm getting error while running this query
help me regarding this

SELECT DISTINCT(table019.col1) DOC_TEMPLATE_ID, VORG.Name SUB_ORGCODE, table019.col2 BRANCH_ID,
TABLE013.col4 REPOSITORY_CODE, TABLE013.col5 REPOSITORY_NAME, table019.col3 REPOSITORY_ID,
table019.col4 CODE, table019.col5 NAME, table019.col4 DOCTYPENAME, table019.col6 DOC_TYPE_ID,
(SELECT col4 FROM table019 WHERE col1 = table019.col7) DOCUMENTCATEGORY,
table019.col7 DOC_CATEGORY_ID, table019.col4 doccon,
table019.col8 doc_id, table019.col9 ECR_REQUIRED,
table019.col10 ATTACH_TEMPLATE, table019.col11 LOCATION, table019.col12 THUMBNAIL_IMAGE,
CASE table019.col13 WHEN '3' THEN 'Closed' WHEN '4' THEN 'In Progress' WHEN '5' THEN 'Pending' WHEN '6'
THEN 'Open' WHEN '9' THEN 'Approved' WHEN '10' THEN 'Rejected' END STATUS, table019.col13 DOCSTATUS,
table019.cold1 BRANCHID, table019.cold2 COMPANYID, table019.cold3 CREATEDBY,
table019.cold4 CREATEDDATE, table019.cold5 LASTUPDATEDBY, table019.cold6 LASTUPDATEDDATE,
table019.cold7 ROWGUID, table019.cold8 UPDATEDSITE, table019.cold9 LANGID FROM table019
Inner Join VORGAN VORG On table019.col2 = VORG.Org_Id Inner Join TABLE013
On table019.col3 = table013.col1 Inner Join table019 On table019.col6 = table019.col1
Inner Join table019 On table019.col8 = table019.col1 where table019.col4 LIKE 'dc%' AND
table019.col13 LIKE '6' OR table019.col13 LIKE '9' and table019.col17 like '%'

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-02-06 : 01:47:24
What error you are getting?
Go to Top of Page

sunil
Constraint Violating Yak Guru

282 Posts

Posted - 2008-02-06 : 01:47:25
What error?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-02-06 : 01:51:36
use this and see if you still get error?
SELECT DISTINCT(table019.col1) AS DOC_TEMPLATE_ID, 
VORG.Name AS SUB_ORGCODE, table019.col2 AS BRANCH_ID,
TABLE013.col4 AS REPOSITORY_CODE, TABLE013.col5 AS REPOSITORY_NAME, table019.col3 AS REPOSITORY_ID,
table019.col4 AS CODE, table019.col5 AS NAME, table019.col4 AS DOCTYPENAME, table019.col6 AS DOC_TYPE_ID,
(SELECT col4 FROM table019 WHERE col1 = table019.col7) AS DOCUMENTCATEGORY,
table019.col7 AS DOC_CATEGORY_ID, table019.col4 AS doccon,
table019.col8 AS doc_id, table019.col9 AS ECR_REQUIRED,
table019.col10 AS ATTACH_TEMPLATE, table019.col11 AS LOCATION, table019.col12 AS THUMBNAIL_IMAGE,
CASE table019.col13 WHEN '3' THEN 'Closed' WHEN '4' THEN 'In Progress' WHEN '5' THEN 'Pending' WHEN '6'
THEN 'Open' WHEN '9' THEN 'Approved' WHEN '10' THEN 'Rejected' END AS [STATUS], table019.col13 AS DOCSTATUS,
table019.cold1 AS BRANCHID, table019.cold2 AS COMPANYID, table019.cold3 AS CREATEDBY,
table019.cold4 AS CREATEDDATE, table019.cold5 AS LASTUPDATEDBY, table019.cold6 AS LASTUPDATEDDATE,
table019.cold7 AS ROWGUID, table019.cold8 AS UPDATEDSITE, table019.cold9 AS [LANGID]
FROM table019
Inner Join [VORGAN VORG] On table019.col2 = VORG.Org_Id
Inner Join TABLE013 On table019.col3 = table013.col1
Inner Join table019 On table019.col6 = table019.col1
Inner Join table019 On table019.col8 = table019.col1
where table019.col4 LIKE 'dc%' AND
table019.col13 = '6' OR table019.col13 ='9'
and table019.col17 like '%'


also i feel you missed something in last where condition (in blue)
Go to Top of Page

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2008-02-06 : 03:05:05
thank you friends
i got the error like this
he column prefix 'TABLE019' does not match with a table name or alias name used in the query.
ok now i rewritten the query now i'm getting. thank you very much

Vinod
Even you learn 1%, Learn it with 100% confidence.
Go to Top of Page
   

- Advertisement -