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.
| Author |
Topic |
|
velnias2010
Posting Yak Master
125 Posts |
Posted - 2011-06-08 : 09:12:38
|
| So I created this viewSELECT TOP (100) PERCENT dbo.tblReports.ID, dbo.tblProducts.Name AS Product, dbo.tblProducts.ID AS productID, dbo.tblReports.Date, dbo.tblReports.Title, dbo.tblReports.FileName, dbo.tblReports.[Document], dbo.tblAccess.CustomerID, dbo.tblReports.WeekYear, dbo.tblReports.Week, dbo.tblReports.Week2FROM dbo.tblAccess INNER JOIN dbo.tblProducts ON dbo.tblAccess.ProductID = dbo.tblProducts.ID INNER JOIN dbo.tblReports ON dbo.tblAccess.ProductID = dbo.tblReports.ProductIDORDER BY dbo.tblReports.Date DESC, dbo.tblReports.Week DESC, dbo.tblReports.Week2 DESC, Product, dbo.tblReports.ProductIDAnd when im editing it and running it works fine.But then when I click save and right click on the view and click on open view it seems to loose the ordering which I specified above.Any Reason ? |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2011-06-08 : 09:21:06
|
| ORDER BY is generally not supported in views so the view designer probably removes it for you even though you have specified the TOP keyword. Views can be used in joins and such and the order would be messed up, so you should ALWAYS use ORDER BY in your final query if you want a specific order. Nothing else will guarantee that data is ordered when it's retured by the database engine.- LumbagoMy blog-> http://thefirstsql.com/2011/02/07/regular-expressions-advanced-string-matching-and-new-split-function-sql-server-2008-r2/ |
 |
|
|
velnias2010
Posting Yak Master
125 Posts |
Posted - 2011-06-08 : 09:33:19
|
| OK Grand Thanks |
 |
|
|
|
|
|
|
|