March 28, 2012 at 10:51 pm
Hi,
I'm trying to keep a copy of all scripts run against a database and their output into a table, but I'm having difficulty keeping the scripts and the output. I can read the contents of a file into a database, but I'm used to it being many lines for many rows. In this case I want the script, line breaks and all, in a single row. Does anyone have any experience with this? As of right now I'm trying to update an existing table record after the fact, but I'm open to anything. I think if I can get the script read in I should be able to do the same with the output.
Here's the t-sql for the table:
CREATE TABLE [dbo].[zScriptExecutions](
[ScriptExecutionID] [int] IDENTITY(1,1) NOT NULL,
[Name] [nchar](200) NOT NULL,
[ExecutionDateTime] [datetime] NOT NULL,
[ChangeRequest] [varchar](10) NULL,
[ExecutedBy] [varchar](200) NULL,
[Comments] [nvarchar](max) NULL,
[ScriptContent] [nvarchar](max) NULL,
[ScriptResults] [nvarchar](max) NULL)
any help would be appreciated.
Thanks,
March 29, 2012 at 2:17 am
I suggest you write down a trigger on the database.
March 29, 2012 at 8:12 am
What are you using to "read the contents of a file into the database" that brings it in as one row per line?
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
March 30, 2012 at 8:07 pm
Bulk insert. I've found a solution, will post when I have a computer.
April 2, 2012 at 8:41 am
A lean Sql Trace definition should fetch you the TSql run against the database.
Why you would want to capture output is one I don't quite understand...
Assuming a script returns a large number of rows.. you intend to capture and store this?
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply