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 |
SQLBoy14
Yak Posting Veteran
70 Posts |
Posted - 2014-12-02 : 13:43:00
|
Hello, how do I just select the top 5 (instead all records by using *) from below open query sample?Select * from openquery ([@Server], ' SELECT * FROM @Schema.customerid ')Thanks guysSQLBoy |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2014-12-02 : 13:44:57
|
Try:Select * from openquery ([@Server], ' SELECT TOP 5 * FROM @Schema.customerid ')Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
SQLBoy14
Yak Posting Veteran
70 Posts |
Posted - 2014-12-02 : 13:45:47
|
that does not work in open query. in normal swl query will work but not in open query. thanks tkizer.SQLBoy |
|
|
SQLBoy14
Yak Posting Veteran
70 Posts |
Posted - 2014-12-02 : 13:57:01
|
actually, I figured it out...it is:Select top 5* from openquery ([@Server], ' SELECT * FROM @Schema.customerid ')SQLBoy |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2014-12-02 : 14:05:46
|
That was going to be my next suggestion. I think that's going to pull back the entire result set and THEN give you TOP 5. I would test to see if that's the case as it could be a performance issue, depending upon the amount of data there is in customerid.Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
|
|
|