Monday, July 23, 2012

sql error dengan order by dalam views

query nya sbb

CREATE VIEW v_tblm_CommonCodeH as
select * from dbo.tblM_CommonCodeH order by commoncode

akan error sbb : The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified.

pemecahannya

perlu ditambahkan
TOP 100 PERCENT
 
query menjadi
 
CREATE VIEW v_tblm_CommonCodeH as
select TOP 100 PERCENT * from dbo.tblM_CommonCodeH order by commoncode

sumber :
http://stackoverflow.com/questions/985921/sql-error-with-order-by-in-subquery

No comments:

Post a Comment