TSQL - What is faster

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.
Amour22015Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dsackerContract ERP Admin/ConsultantCommented:
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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Vitor MontalvãoMSSQL Senior EngineerCommented:
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
Amour22015Author 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ãoMSSQL Senior EngineerCommented:
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.
Amour22015Author Commented:
Ok so just the select command is faster, thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.