TSQL - What is faster

Amour22015
Amour22015 used Ask the Experts™
on
Hi Experts,


This is more of an informational question

I have a co-worker that said that I should not:
Right click a table and take the option of: "Select top 1000 rows"
that it take more time to do this.

The co-worker said that it is best to:
just do new query and then type in your select statement.

But one would have to know all the columns in the select statement to do this?

So what approach is best?

Thanks for helping.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Contract ERP Admin/Consultant
Commented:
You don't have to know all the columns.

SELECT * FROM YourTable
Or if you just want to see 100 rows (if it's a big table, this is wise):

SELECT TOP 100 * FROM YourTable
The asterisk (*) will show all columns.

The nice thing about playing in the query window (or actually, you could call it "data mining") is that once you list them all, you can narrow your SELECT down to just the columns you want to see.
Vitor MontalvãoIT Engineer
Distinguished Expert 2017
Commented:
Use the Script Table option for SELECT To a new query editor window. Will give you all the columns and without the TOP 1000.
SelectTo.PNG

Author

Commented:
But that would run all rows and might take awhile?

maybe Select top 1000 *  From table?

So doing just the select statement is faster?

Thanks
Vitor MontalvãoIT Engineer
Distinguished Expert 2017

Commented:
Is not even a speed matter. Do you really want to return all rows or only the first 1000?
If you want all rows then TOP 1000 can't be a solution for you.

Author

Commented:
Ok so just the select command is faster, thanks

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial