SQL Scripts - How to run and get results

  • Good Morning,

    I am very new to SQL. I am trying to run a SQL on a table to see what changes were made to the system.

    Can I use one that's on my system in a folder entitled SQL Scripts? or do I need to create one.

    I am using MSSQL Server 2000 and I Query Analyzer and received error message, table already created.

    How do I get results of the query?

    Thank you for your help.:-)

  • To get results from a table, you do this:

    Select * from yourtablename

    It sounds like you did this:

    create table yourtablename (col1 varchar,col2 varchar)

    Or something to that effect.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • Thank you for stating you are using SQL Server 2000 in your initial post. Please, in future, be sure you post your questions in the appropriate forums as this is a SQL Server 2008 forum, and you may get answers that won't work in SQL Server 2000, especially if you DON'T inform people that you are using SQL Server 2000.

  • glee777 (1/22/2010)


    ... I am trying to run a SQL on a table to see what changes were made to the system.

    Can I use one that's on my system in a folder entitled SQL Scripts? or do I need to create one. ...

    I'm not sure what you mean by this.

    Are you trying to find changes to the data in a table, or trying to find changes to the structure of a table?

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • As per the question concerning running a script from a folder or needing to create a new script. That depends - both are viable options.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • Thank you Lynn. 🙂

  • Thank you for your response.

    I am trying to find if any changes were made to the table. In this instance a Table was deleted and need to know who deleted it.

    There is an SQL Files in a Scripts Folder where looks like a query is written that asks it to create a table, but what I am wanting to do is create a log of any changes on that particular table.

    Hope this makes sense.

    Again, thank you for your help and patience with helping me to understand.

  • glee777 (1/22/2010)


    Thank you for your response.

    I am trying to find if any changes were made to the table. In this instance a Table was deleted and need to know who deleted it.

    There is an SQL Files in a Scripts Folder where looks like a query is written that asks it to create a table, but what I am wanting to do is create a log of any changes on that particular table.

    Hope this makes sense.

    Again, thank you for your help and patience with helping me to understand.

    To setup auditing, I would recommend you enable c2 auditing or setup a trace.

    To find out who dropped the table - it's too late for the one already dropped.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • There's a report you can get on schema changes. Deleting a table is a schema change.

    Right-click on the database in Management Studio, and select Reports, then select Schema Changes. It should tell you when the table was deleted and some details about that.

    See if that gives you what you need.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • GSquared (1/22/2010)


    There's a report you can get on schema changes. Deleting a table is a schema change.

    Right-click on the database in Management Studio, and select Reports, then select Schema Changes. It should tell you when the table was deleted and some details about that.

    See if that gives you what you need.

    Even for SQL 2000?

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • CirquedeSQLeil (1/22/2010)


    GSquared (1/22/2010)


    There's a report you can get on schema changes. Deleting a table is a schema change.

    Right-click on the database in Management Studio, and select Reports, then select Schema Changes. It should tell you when the table was deleted and some details about that.

    See if that gives you what you need.

    Even for SQL 2000?

    Nope. Saw this was in the SQL 2008 forum and missed that it was about SQL 2000.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • GSquared (1/23/2010)


    CirquedeSQLeil (1/22/2010)


    GSquared (1/22/2010)


    There's a report you can get on schema changes. Deleting a table is a schema change.

    Right-click on the database in Management Studio, and select Reports, then select Schema Changes. It should tell you when the table was deleted and some details about that.

    See if that gives you what you need.

    Even for SQL 2000?

    Nope. Saw this was in the SQL 2008 forum and missed that it was about SQL 2000.

    It threw a couple of us for more than a minute trying to help

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • I've never done it so don't know for sure but rumor has it that C2 auditing is rather fierce in the amount of data it captures. I'm not sure I'd recommend it unless it was imperative to have it.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 13 posts - 1 through 12 (of 12 total)

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