Link to home
Start Free TrialLog in
Avatar of Rdichpally
RdichpallyFlag for United States of America

asked on

Log File for Drop and Create Table

I have many Drop and Create Table/ Views statements that I need to automate and log into a file when I run the script. Basically, I need to create a Log file for that will Log all the Drop and Create tables statements and will give me a status of the operation after the SQL statements have been run.

Any help on this issue is appreciated.
Avatar of lcohan
lcohan
Flag of Canada image

I suggest you add a DDL Database Trigger and that will log into a table all the operations you need on DROP/CREATE/ALTER any SQL object in that database.

http://technet.microsoft.com/en-us/library/ms186406(v=sql.105).aspx

"SQL Server DDL Triggers to Track All Database Changes"
http://www.mssqltips.com/sqlservertip/2085/sql-server-ddl-triggers-to-track-all-database-changes/


I also suggest you right click your database in SSMS and check the standard report "Schema change history" for that same matter
Avatar of Rdichpally

ASKER

I need to create a log file when I run my DDL statements. I basically need a script for creating log files for a bunch of DDL Statements (Drop and Create tables). Thanks.
"I need to create a log file when I run my DDL statements"

The DDL database trigger example I posted above has ALL the code for you and it populates a log table already from where you can create your "log files" whatever those would be. To be honest I'm not sure what easier and better solution than this to LOG all DDL changes you need?

"The approach is to take a snapshot of the current objects in the database, and then log all DDL changes from that point forward. With a well-managed log, you could easily see the state of an object at any point in time (assuming, of course, the objects are not encrypted)."
ASKER CERTIFIED SOLUTION
Avatar of Rdichpally
Rdichpally
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
No Solution suggested for the issue
I've requested that this question be closed as follows:

Accepted answer: 0 points for Rdichpally's comment #a39970748

for the following reason:

There was no solution suggested for my request that solves my issue
No Valid solutions for my issue