Indexes + Excel Question

  • Hi

    in the new fangled way of writing SQL (I dont know what the technical term is) you would write

    Select fielda,fieldb,fieldc from TbleA inner join TblB on TbleA.FieldX = TbleB.FieldY where ...

    My question is on indexes. Do indexes include the filter part ie. the where clause or just fields in the FROM clause?

    Does anyone have a link to something about indexes and how best to use them? I'm always confused on whether to choose all fields that are used in a query for an index or a subset of fields, that being the most selective. So FldA,FldB,FldC are being used in a query and FldC is not that unique then would the index be FldA,FldB,FldC or FldA,FldB?

    A question about Excel. I want to dump a table/view from SQL into an excel file and email it to a user. Is that possible?

    Sorry for mixing topics...

  • urmarke (10/22/2010)


    Hi

    Select fielda,fieldb,fieldc from TbleA inner join TblB on TbleA.FieldX = TbleB.FieldY where ...

    My question is on indexes. Do indexes include the filter part ie. the where clause or just fields in the FROM clause?

    your query will be

    select column_name/s from table where columnname = whatever..

    Index is part of hint in query which you can force query to use that index like..

    WITH (INDEX(index name))

    I will suggest first have an understanding on type of index and its use...have a look of this article..

    http://www.simple-talk.com/sql/database-administration/brads-sure-guide-to-indexes/

    A question about Excel. I want to dump a table/view from SQL into an excel file and email it to a user. Is that possible?

    use SSIS or import export wizard.

    Or more simple...if you want to see all the records of a perticular table in excel, then open excel, go to data--from other source--from sql server.

    Provide your sever name and authentication type and then your database and table. you will get the result in excel.

    ----------
    Ashish

  • You really don't need to start putting on index hints yet, no.

    Yes, indexes work with the columns in the SELECT clause, the WHERE clause and the ON parts of the FROM clause. Indexes and indexing is a huge topic. There are simply tons of links. I think the best place to start would be with the Microsoft documentation. Here's their introduction to indexes. That should get you started.

    Please don't start putting hints into the query. Hints are a last resort when you've tried every other method of tuning the query to get it to use appropriate indexes. You're not anywhere close to there yet.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • I never suggested to use the query in hint...I was just giving explnation on the use.

    And like you also mentioned, he need to familarise with the term first before use.

    ----------
    Ashish

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply