• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 364
  • Last Modified:

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.
0
Rdichpally
Asked:
Rdichpally
  • 5
  • 2
1 Solution
 
lcohanDatabase AnalystCommented:
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
0
 
RdichpallyAuthor Commented:
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.
0
 
lcohanDatabase AnalystCommented:
"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)."
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
RdichpallyAuthor Commented:
I've requested that this question be closed as follows:

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

for the following reason:

No Solution
0
 
RdichpallyAuthor Commented:
No Solution suggested for the issue
0
 
RdichpallyAuthor Commented:
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
0
 
RdichpallyAuthor Commented:
No Valid solutions for my issue
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now