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 |
sign_seventh
Yak Posting Veteran
66 Posts |
Posted - 2007-04-12 : 03:55:14
|
Hi guys,what is the right syntax for< select TOP (select count(*) from tablename) >is is possible?thnx |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-04-12 : 03:57:56
|
Did you get any error when you tried?Peter LarssonHelsingborg, Sweden |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-04-12 : 03:59:08
|
[code]SELECT TOP (SELECT COUNT(*) FROM sys.sysobjects) *FROM master..spt_values[/code]Peter LarssonHelsingborg, Sweden |
|
|
sign_seventh
Yak Posting Veteran
66 Posts |
Posted - 2007-04-12 : 04:05:53
|
FOR EXMPLE:select top (select count(*) from GRP_GROUPS) GRP_GROUP_ID from GRP_GROUPSERROR MSG:Server: Msg 170, Level 15, State 1, Line 1Line 1: Incorrect syntax near '('.Server: Msg 170, Level 15, State 1, Line 1Line 1: Incorrect syntax near 'GRP_GROUP_ID'. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-04-12 : 04:15:14
|
You know that dynamic TOP value only applies to SQL Server 2005?If you are using SQL Server 2000,DECLARE @X INTSELECT @X = COUNT(*) FROM Table1SET ROWCOUNT @XSELECT * FROM Table2SET ROWCOUNT 0Peter LarssonHelsingborg, Sweden |
|
|
sign_seventh
Yak Posting Veteran
66 Posts |
Posted - 2007-04-12 : 04:20:49
|
ok thnx |
|
|
|
|
|