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 |
|
pwcphoto
Yak Posting Veteran
69 Posts |
Posted - 2005-07-18 : 02:23:48
|
| Is it ok to use Select TOP in a select statement and use Select Top in as Subsect within the same query?From BOL "The TOP clause applies to the single SELECT statement in which it is specified."Does this mean Only one time in the entire query or just that select and not the subselectas in the follwoing?'SELECT ' + @strFields + ' FROM ' + @strTables + ' WHERE ' + @strPK + ' IN ' + ' (SELECT TOP ' + @strPageSize + ' ' + @strPK + ' FROM ' + @strTables + ' WHERE ' + @strPK + ' NOT IN ' + ' (SELECT TOP ' + @strSkippedRows + ' ' + @strPK + ' FROM ' + @strTables + @strFilterCriteria + @strGroupCriteria + @strSortCriteria + ') ' + Thanks,Phil-----------------------I used to be a rocket scientist. Now I'm just a space cadet... |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-07-18 : 02:39:11
|
| Yes you can use "The TOP clause applies to the single SELECT statement in which it is specified."Select top 10 columns from table --Limit to 10 rowsSelect columns from table--top not valid hereBut setting rowcount will limit all the selects until it is reset to 0MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|