Text Variable In TRIGGER

May 19, 2006

recently I wrote a TRIGGER , but I found the text is not allowed to be used.

such as:

in the trigger:

declare @content text

Is it illegal???  And why?

thank you!

View 7 Replies


ADVERTISEMENT

Drop Trigger With A Variable Trigger Name

Sep 20, 2007



Hi all in .net I've created an application that allows creation of triggers, i also want to allow the deletion of triggers.
The trigger name is kept in a table, and apon deleting the record i want to use the field name to delete the trigger

I have the following Trigger

the error is at

DROP TRIGGER @DeleteTrigger

I'm guessing it dosen't like the trigger name being a variable instead of a static name
how do i get around this?

thanks in advance

-- ================================================

-- Template generated from Template Explorer using:

-- Create Trigger (New Menu).SQL

--

-- Use the Specify Values for Template Parameters

-- command (Ctrl-Shift-M) to fill in the parameter

-- values below.

--

-- See additional Create Trigger templates for more

-- examples of different Trigger statements.

--

-- This block of comments will not be included in

-- the definition of the function.

-- ================================================

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

-- =============================================

-- Author: <Author,,Name>

-- Create date: <Create Date,,>

-- Description: <Description,,>

-- =============================================

CREATE TRIGGER RemoveTriggers

ON tblTriggers

AFTER DELETE

AS

BEGIN

-- SET NOCOUNT ON added to prevent extra result sets from

-- interfering with SELECT statements.

SET NOCOUNT ON;

Declare @DeleteTrigger as nvarchar(max)

select @DeleteTrigger = TableName FROM DELETED



IF OBJECT_ID (@DeleteTrigger,'TR') IS NOT NULL

DROP TRIGGER @DeleteTrigger

GO

END

GO

View 7 Replies View Related

Column Name As Variable In Trigger

Jun 7, 2001

I am writing an audit trail trigger that needs to query columns, but the specific column names are not known until the trigger runs and determines what columns have changed. Once I know the changed column(s) I fetch the column name. No sweat.
The problem is using a variable in place of a column name I can not get the data to return, only the column name.

-- Here is how I get the column name. It works great, @CName
-- reflects the column name as I use it elsewhere fine.
Select @CName = col_name(OBJECT_ID('TABContract'), @CNum)

-- This simple syntax usually works, it does not using a
-- variable as the column name. @Prev is populated with
-- @CName literally. I have tried various and asundry ()'s and []'s
Select @Prev = @CName From Deleted

-- Here I have hard coded the Column name and ran a test modifying that column "Comment" and it works! @Prev is populated with the columns data not the Column name.
Select @Prev = Comment From Deleted

-- Tried these syntaxes, no luck
Select @Prev = (Select @CName From Deleted)
Select @Prev = (Select col_name(OBJECT_ID('TABContract'), @CNum) From Deleted)


Any help appreciated,
Ray
rwood@semcorp.com

View 2 Replies View Related

Using A 'ntext' Variable In A Trigger

Sep 9, 2004

Hello, I have a very simple trigger that only copies the data from one table to a historial table, when a row is deleted. It works fine, but now I need to change it becouse I am inserting a new column to the table, which type is ntext, and when I try to declare a ntext variable (inside the trigger), it does not allow me. Does anyone know how to go round this? Here is the code of the trigger (maybe it is not efficient, as I am a newbie in this :D, please tell if so as well)


CREATE TRIGGER OnDelete ON dbo.Tracker
FOR DELETE
AS

declare @IDregistro as integer;
declare @IDTIT as integer;
declare @negocio as nvarchar(50);
declare @fechaOr as datetime;
declare @asuntoOr as nvarchar(50);
declare @estadoOr as nvarchar(50);
declare @descripcionOr as nvarchar(255);
declare @usuarioOr as nvarchar(50);
declare @contactoOr as nvarchar(50);
declare @companiaOr as nvarchar(40);
--declare @desc as ntext; --DOES NOT WORK!!

declare @fechaSus as datetime

select @fechaSus = getdate()

select @IDregistro = IDregistro from deleted;
select @IDTIT = IDTitular from deleted;
select @negocio = negocio from deleted;
select @fechaOr = fecha from deleted;
select @asuntoOr = asunto from deleted;
select @estadoOr =estado from deleted;
select @descripcionOr = descripcion from deleted;
select @usuarioOr = usuario from deleted;
select @contactoOr = contacto from deleted;
select @companiaOr = compania from deleted;

insert into Historico (IDregistro, IDtitular, Negocio, FechaSuceso,TipoSuceso, FechaOriginal, AsuntoOriginal, EstadoOriginal, DescripcionOriginal, UsuarioOriginal, ContactoOriginal, CompaniaOriginal) Values (@IDregistro, @IDTIT, @negocio, @fechaSus, 'DELETE', @fechaOr, @asuntoOr, @estadoOr, @descripcionOr, @usuarioOr, @contactoOr, @companiaOr)

View 5 Replies View Related

Application Variable In A CLR Trigger

Apr 30, 2008

Is it possible to get a variable( for example user id of the currently logged in user) in a CLR SQL Server trigger.

View 1 Replies View Related

Connection Level Variable For Trigger Use Possible?

May 19, 2008

I need to pass a application userid on every call to my database for triggers on the db to use.


I am connecting to my database using integrated security from my application, all on one windows domain account. However I need to get an application user id over on the connection for triggers to use to stamp in changelogs.


Currently everytime we open a connection we create a #table with the user id in it, but that is expensive, especially in our new SOA where connections are frequently created and dropped on requests.


Is there any way I can get a connection level variable over to the database server so triggers could read it?

Any help is greatly appreciated.

View 1 Replies View Related

Local Variable Assignment In CREATE TRIGGER

Mar 7, 2006

Hi Guys,

i'm batttling with the below Trigger creation

__________________________________________________ _
CREATE TRIGGER dbo.Fochini_Insert ON dbo.FochiniTable AFTER INSERT AS
BEGIN
DECLARE @v_object_key VARCHAR(80)
DECLARE @v_object_name VARCHAR(40)
DECLARE @v_object_verb VARCHAR(40)
DECLARE @v_datetime DATETIME

SELECT ins.Cust_Id INTO @v_object_key FROM inserted ins <--- my problem area!!
SET @v_object_name = 'FochiniTable'
SET @v_object_verb = 'Create'
SET @v_datetime = GETDATE()

IF ( USER <> 'webuser' )
INSERT INTO dbo.xworlds_events (connector_id, object_key, object_name, object_verb, event_priority, event_time, event_status, event_comment)
VALUES ('Fochini', @v_object_key, @v_object_name, @v_object_verb, '1', @v_datetime,'0', 'Triggered by Customer CREATE')

END
________________________________________________

i'm trying to get the INSERTED variable from table FochiniTable on colomn Cust_Id

and the statement: SELECT ins.Cust_Id INTO @v_object_key FROM inserted ins - is failing [still a newbie on mssql server 2000]

any help will be appreciated
lehare.

View 1 Replies View Related

How To Create Trigger Which CREAT TABLE From A Variable String?

Feb 23, 2006



I have a Table Name "Forums". I want to ceate an AFTER-Trigger on it. It will execute when ever a new row is inserted to "Froums" Table.

Here is what I did but It needs to be corrected:

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

ALTER TRIGGER CreateTopicsTableTrigger

ON dbo.Forums

AFTER INSERT

AS

SET NOCOUNT OFF

DECLARE @myNewForum varchar

CAST(@@ROWCOUNT as varchar) /*Is it OK???*/

SET @myNewForum=@myNewForum+@@ROWCOUNT /*Here I dont know how assigments work in SQL*/

GO

CREATE Table @myNewForum /*Will this work some how???*/

( TopicID int IDENTITY NOT NULL, TopicTitle varchar(50) , CreatedBy varchar(50) ,

DateCreated DateTime , DateLastUpdate DateTime , LastUpdateBy varchar(50) )



::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

View 5 Replies View Related

Combining Text And Value In Trigger

Nov 30, 2005

Hi,

I have written a trigger that emails a specified person.

I am trying to include a body of the email which comprises of the stock level and a warning. Pulling out my hair...Help

Code so far in the trigger is :

CREATE TRIGGER Warnings ON [dbo].[tbl_sql_cartridges_kh]
for update
AS
declare @SL as int
declare @SS as int
declare @Msg as nvarchar(100)
set @SL= (select stock_level from inserted)
set @SS =(select cartridge_key from inserted)
set @Msg = 'Print Cartridges Level Warning'
if @SL < 3
begin

exec sp_send_cdontsmail 'Print-Cartridges','XXX@XXXX.co.uk','Print Cartridges Level Warning',@Msg
end

I would like the @Msg to say something like Cartridge XXX stock level is YYY, where XXX and YYY are taken from the table after update. I can get the values, but cant put them in the MSG string..

Like @msg & @SL (SL being Stock Level)

Many Thanks

Ken

View 2 Replies View Related

Text Local Variable

Jan 17, 2007

Hi All,

How to declare TEXT datatype as local variable . My data is getting truncated as it cross varchar(8000) characters.

Saju

View 1 Replies View Related

Variable And Text File

Nov 30, 2007

Hi All,

I was wondering if anybody knows how to put the values in the variable to a text file. I have a stored procedure that has a cursor that pulls certan records and then place them into a variable. I want to put the variable values into a text file. Any ideas?

Thanks.

View 3 Replies View Related

Text String As Variable?

May 9, 2014

I want to run the following code:

Declare@Testnames as Varchar(500)
Set@Testnames = ('CT,MRI')-- List all radiology type
SELECT*
FROMRPT_OUTPATIENT_IMAGING
WHEREservice_level2 In (@Testnames)

Nothing comes back.

When I run:

SELECT*
FROMRPT_OUTPATIENT_IMAGING
WHEREservice_level2 In ('CT','MRI')

Then I get results.

View 5 Replies View Related

Trigger And Text Data Type

Dec 6, 2000

Hi All,
I have the code below on Sql 2k table with the column Descriptivetext defined as
Text Data Type. The table has Path and Page as the PK
I need to set a trigger to update Desciptivetext in other rows with the same path
when a one of them chnages.
Whenever I run the code, no row is updated

CREATE TABLE [dbo].[AB] (
[PATH] [varchar] (255) NOT NULL PRIMARY KEY CLUSTERED ,
[PAGE] [varchar] (60) NOT NULL PRIMARY KEY CLUSTERED ,
[DESCRIPTIVETEXT] [text] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

CREATE TRIGGER [Update_Staging_Test] ON [dbo].[AB]
INSTEAD OF UPDATE
AS

Declare @TextPointer as Varbinary (16), @NewTextPointer as Varbinary (16), @Path
varchar(255), @Page as varchar(60), @DescriptiveText as varchar(7000)
If Update(DescriptiveText)
--Get the Path of the record from Inserted
Select @Page = Page, @Path = Path , @DescriptiveText = Cast(DescriptiveText as
Varchar(7000))
from Inserted


UPDATEAB
SETDescriptiveText = Cast (@DescriptiveText as Text)
WHEREPath = @Path




Rgds
GERI

View 5 Replies View Related

Text Data Type In Trigger

Feb 22, 2007

Hi,

I am using following query to get insereted records from a table, which is containing a column, having text datatype.

'SELECT * INTO #TEMP FROM INSERTED'

Then obviously it gives error.

Wat if i want to get all the columns from inserted table excluding the text datatype column, without giving the column names.

Thanks & Regards.
Shabber.

View 1 Replies View Related

Create Text File And Ftp With Trigger

May 24, 2007

Good day,

I hope someone can help me.

Question 1:
Is it possible to create a text file from a sql server trigger?

Question 2:
Is it possible to ftp a file from a sql server trigger?

Please if anyone can help I would appeciate it.

Thanks

View 10 Replies View Related

T-SQL (SS2K8) :: Trigger With Text Type?

Aug 14, 2014

Dealing with 3rd party app that is somehow deleting records. Was going to put a delete trigger on the table so we can at least be notified of the delete and save the record. Great idea until I found out the table has a text data type for one of the fields which are'nt allowed on the delete or update portion of the trigger. Unfortunately the text data contains what we really need to retain. Tried doing a convert varchar and that would not work.

View 7 Replies View Related

Create Trigger To Format Text

Mar 4, 2015

We are using an old version of Numara TrackIT for our helpdesk software, and it doesn't have much in the way of configurable options. There is no way to set validation or formatting on the text fields in the program.

There is a field, WO_TEXT1, Which I would like to be formatted as 6 characters, 3 integers + a period + 2 integers. The first the integers would be padded with zeros on the left, and the last 2 integers would be padded with zeros on the right.

IE, if someone enters 2, it would actually end up being 002.00
If someone enters 3.5 it would end up being 003.50
If someone enters 12.1 it would end up being 012.10
If someone enters 172.80 it would end up being 172.80

I was hoping to achieve this via an update trigger.

Below is the guts of the trigger I created, mostly as a proof of concept.

-- This update properly formats the Estimated Hours field
Update t SET WO_TEXT1 = (SELECT RIGHT('000000' + CONVERT(VARCHAR(6), WO_TEXT1), 6) FROM inserted)
FROM dbo.TASKS as t
Where (EXISTS (SELECT * FROM inserted WHERE WOID = 24773));

I expected that this update trigger would only affect the Work Order with a WOID of 24773. Unfortunately, it updated all 21000 work orders in our system, wiping out all of the actual estimated hours that had been inserted by technicians!

Luckily I had a report that I could quick dump the 300 or so active work order's estimated hours back into the DB from (all the other Work orders are closed, and no one really cares about their estimated hours).

My question is three fold,

1) Why did my trigger update every record in the tasks table instead of just WO 24773?
2) Is using a trigger the best way of accomplishing what I'm trying to do?
3) if a trigger is the best way of accomplishing this, what should my trigger look like?

View 12 Replies View Related

Getting First 200 Chars Of Text Stored In Variable

Apr 21, 2008

Hi all,I have a variable called Description which is set from a database field - How do i set another variable to grab the first 200 chars from this var?
hope this makes sense
 

View 2 Replies View Related

Using TEXT Datatype As Local Variable In SP Or UDF

Mar 12, 2003

I've created a stored procedure that converts an input string in richtext format (input as type TEXT) to plain text. I would like to be able to return this newly converted string, but I need to have some way of storing it in a local variable. My problem is that since I can't use the TEXT datatype as a local variable, I have no way of storing the large amounts of text I converted within the procedure. The VARCHAR(8000) just isn't large enough for my purposes. Anyone have any suggestions on how to go about doing this?

View 2 Replies View Related

SQL 2012 :: How To Assign Text To A Variable

Sep 22, 2015

I have this big huge SQL statement. I am trying to see whether there is some quick magic way to assign it to the variable @SQL

Declare @SQL NVARCHAR(MAX)
Set @SQL = <????>
SELECT ClaimSurgical.FormNbr as ClaimIdentifier,ClaimSurgical.MemberTID, ClaimSurgical.Membernbr as MemberNumber, ClaimSurgical.AdmitDate AS ServiceDateYYYYMMDD,
CAST(CAST(ClaimSurgical.AdmitDate AS VARCHAR) AS DATETIME) ServiceDate,ClaimSurgical.ProviderNbr as ClaimPRVNO, ClaimSurgical.VendorNbr as ClaimTaxID,
ClaimSurgical.AssignedProvider1 as PCPPRVNO,ClaimSurgical.CAPVendor as PCPTaxID, EventCode_1.EventCodeTypeID,

[code]....

View 5 Replies View Related

How To Add Variable To Sql Command Text Field

Sep 7, 2007

In the data flow task I have multiple OLE DB source task to retreive data from a cube using MDX. Below is an example of the query from sql command text field: I have a few questions on how to modify this statment to make it more robust.

1) The where clause [Calendar].[Quarter 2 (2007)] should actually be some kind of variable that will change each time
the user runs this project. So I am wondering how to make this a variable and get it into this field.

2) I had thought that I could use the SSIS variable. I have created one, but I can not figure how to get it into the field that
contains the given select statment.

3) I believe that once I get this variable part to work then I want a way to have user set this data value. Either by selecting data from a table in database or through a user interface where user enters data. I did do some resarch on creating a user interface, but I did not understand what I had to do, so if any one knows where to find a tutorial on how to do this let me know, or what they believe the best/easiest way is to get data from user to fill this where clause.
select * from OPENROWSET('MSOLAP', 'DATASOURCE=local; Initial Catalog=Patient Demographics 2005;',
'with member [Measures].[TimeDisplayName] as [Calendar].CurrentMember.Name
SELECT NON EMPTY { [Measures].[TimeDisplayName],[Measures].[Adjusted Relative Weight],[Measures].[Adjusted Case Weight]} ON COLUMNS,
({[Facility].[REGION].[NATCODE], [Facility].[REGION].[REGCODE]} *
[RIC].[CMGGRPCD].ALLMEMBERS) ON ROWS FROM [ESR]
WHERE [Calendar].[Quarter 2 (2007)]
')

View 10 Replies View Related

Using Variable In DataReader's SqlCommand Text

Jan 17, 2007

I'm attempting to configure a DataReader's SqlCommand text to use a package-level variable and I'm having trouble. I've read about using the "sql command from variable" option but although I see that during the configuration of Ole DB source, I don't see the same option for DataReader source. Viewing the properties of the DataReader and selecting the SqlCommand property does have button to configure the value but only displays a string value editor window. (I was hoping for the expression editor.)

The configured connection to the DataReader uses the odbc Data Provider (under .Net providers). I'm connecting to mySql, if that matters.

What I'm looking to do is to use a variable in the where clause of the DataReader's SqlCommand. Any hints how to accomplish this or other ideas would be greatly appreciated.

Thanks

View 4 Replies View Related

Text Datatype As Local Variables In Trigger

Dec 12, 2005

Friends,I would just like to know that why SQL Server doen't allow us to definea text data type local variable while creating trigger?I tried creating a text variable in a trigger as a local variable andit raises error."Implicit conversion from data type text to nvarchar is not allowed.Use the CONVERT function to run this query".For this i have to use convert function in MS SQL Server.-ThanksBhavin Vyas

View 1 Replies View Related

Text Data Type From Deleted Table (trigger)

Feb 12, 2003

Hi,

I need to prevent modification/update to a field.

So I created a trigger. To take the data from DELETED table then replace the field data.

However, I have problem with one field which data type is text.

MS SQL always return me this error:
Cannot use text, ntext, or image columns in the 'inserted' and 'deleted' tables.

I use the following code to take the data from deleted table

DECLARE @ptrval varbinary(16)
SELECT @ptrval = TEXTPTR(NOTES )
FROM DELETED

I also tried simple Select statement
Select notes from deleted

What code should I use to take the deleted data

Please help.

Thanks in advance

View 9 Replies View Related

Insert Trigger And Xp_cmdshell With Carriage Return Text

Jul 20, 2005

I have created the following trigger:CREATE TRIGGER [CreateFile] ON OutputTableFOR INSERTASDeclare @filename nvarchar(35)Declare @filecontents nvarchar(2000)Declare @strcmdshell varchar(150)SELECT @filecontents = OutputText FROM INSERTEDSELECT @filename = 'c:' + OutputFileName FROM INSERTEDSELECT @strcmdshell = 'echo '+ @filecontents+ ' >'+ @filenameexec master..xp_cmdshell @strcmdshellIt works fine as long as the column OutputText has no carriagereturns.I have used my Access2K front end to dump about ten lines of text intoOutputText, each line broken by vbcrlf so that OutputText looks like:line1testline2textline3textetc.The trigger won't fire with this text.Is there something I can do to remedy this?lq

View 4 Replies View Related

BULK Insert From A Text File Name Stored Into A Variable

Mar 25, 2004

Hello I need to write a proc to load data from txt files I receive into a table. It works fine when I specify
bulk insert.... from 'myfilename.txt'
BUT my filename will always change and I store it into a variable @filename

When I try to run the bulk insert instruction ... from @filename it doesn't work..
do you know why?

Thank you in advance

View 1 Replies View Related

How? : Using A Varchar, Text Data Type Variable As Valid Column Name.

Jun 2, 2008

Cannot use dynamic sql in current context. So need some help regarding this.I am developing a stored procedure to update a table. Sending Column names as parameters, but not able to use them as given below.INSERT INTO Books (@Column1, @Column2) values.. Any way to execute without using dynamic sql?..Thanx.   

View 1 Replies View Related

SSIS Newbie Question - Get Strings From Text File Into A Variable

Aug 23, 2007

HI All. I'm trying to tweak the Transfer Logins task to exclude Windows Logins that are local to the Server (e.g. servernameusername) which obviously can't be transferred off the server. Annoying that we have a couple of local Logins on this system instead of all Domain Groups, but we're stuck with them due to firewall issues, and a policy excluding SQL Logins.

My idea is to create a text file as part of my Package that lists Logins to be Excluded From the Transfer - I think I then need to create a New File Connection to the Text File as a Connection Manager, then somehow get that data into a Variable, and then use an Expression to populate the 'LoginsList' Collection from syslogins where loginame not equal to logins in my textfilevariable?

Or maybe I'm over complicating this, and there's an easier solution? Lots of info in Books Online about Expressions and Variables, but having trouble finding examples that I can use. As a DBA, this is my first foray into SSIS, and as you can possibly tell, I'm floundering....

View 1 Replies View Related

T-SQL (SS2K8) :: Trigger To Call A Program To Write Text File Onto A Folder In Server

Apr 29, 2014

I have created a trigger to call a program that is written by our program. The program is basically read the record in the table and write to a text file, then delete the record from the table.

The trigger is a after insert trigger. After we added the trigger, we insert a record to the table. The result is that the record still and did not get deleted. Also, the text file didn't get created either. It seems that it take a long time for the record to be written to the table.

But if we just run the program (a exe file), it can write a text file in the folder and delete the record. the trigger is basically:

USE [Zinter]
GO
/****** Object: Trigger [dbo].[ZinterProcess] Script Date: 04/29/2014 18:34:56 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

[Code] ....

View 9 Replies View Related

Integration Services :: How To Read A Specific String From Text File As Output Variable In SSIS

Nov 5, 2015

I am downloading a webpage as a text file in order to read a specific string to assign it as a variable/parameter in order to create an output file name. I would like to know how would I be able to look for a specific string and output as another variable for the rest of the package.

2015 Conforming Loan Limits
------------------------------------------------------------------------
o _Loan Limits for Calendar Year 2015--All Counties _[XLS]
</DataTools/Downloads/Documents/Conforming-Loan-Limits/FullCountyLoanLimitList2015_HERA-BASED_FINAL_FLAT.xlsx>_ ,
_[PDF]
</DataTools/Downloads/Documents/Conforming-Loan-Limits/FullCountyLoanLimitList2015_HERA-BASED_FINAL.pdf>_
​ o _List of 46 Counties with Increases in Loan Limits for 2015

[Code] ...

To explain it a more better way, I have a sample webpage text here. I should be searching for "FullCountyLoanLimitList" appended by the current year (like FullCountyLoanLimitList2015) and copy the entire file name in the text file and assign it to another variable so that I can download that specific file using WebClient connection.

View 4 Replies View Related

Using A Variable In SSIS - Error - Command Text Was Not Set For The Command Object..

Nov 4, 2006

Hi All,

i am using a OLE DB Source in my dataflow component and want to select rows from the source based on the Name I enter during execution time. I have created two variables,

enterName - String packageLevel (will store the name I enter)

myVar - String packageLevel. (to store the query)

I am assigning this query to the myVar variable, "Select * from db.Users where (UsrName = " + @[User::enterName] + " )"

Now in the OLE Db source, I have selected as Sql Command from Variable, and I am getting the variable, enterName,. I select that and when I click on OK am getting this error.

Error at Data Flow Task [OLE DB Source [1]]: An OLE DB error has occurred. Error code: 0x80040E0C.
An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80040E0C Description: "Command text was not set for the command object.".

Can Someone guide me whr am going wrong?

myVar variable, i have set the ExecuteAsExpression Property to true too.

Please let me know where am going wrong?

Thanks in advance.








View 12 Replies View Related

XML TASK XSL Variable: Exception 'Property New Source Has No Source Xml Text'

Dec 20, 2005

Hi,
I want to transform an xml flow to an html flow. For this, I create an XmlDataDocument, I add on it, all that I want, and I store it in a file (in a dataflow task).
After that, in an xml task, I set the input properties like that:
Operation type: xslt
SourceType: File connection
Source: ras.xml
 
All works fine. But now, I want to use a variable to store my xml data. So, instead of storing my data in ras.xml, I store it in a variable like that:
 
Dim v As Microsoft.SqlServer.Dts.Runtime.Wrapper.IDTSVariables90
Me.VariableDispenser.LockOneForWrite("RAS", v)
v("RAS").Value = doc.OuterXml
v.Unlock()
 
and in the xml task, I set configuration like that:
 
Operation type: xslt
SourceType: Variable
Source: user::RAS
 
But when I execute, I got this following exception:
 
Error: 0xC002F304 at Format HTML Mail, XML Task: An error occurred with the following error message: "Root element is missing.".
Error: 0xC002928F at Format HTML Mail, XML Task: Property "New Source" has no source Xml text; Xml Text is either invalid, null or empty string.
 
Furthermore, when I want to debug it, in replacing the xml task, by a script task, I can see that in my RAS variable, I get the xml data which is well formed.
 
<?xml version="1.0" encoding="UTF-8"?>
<root> €¦
</root>
 
(When I store it in a file, I can see it in IE)
 
Have you got an idea ?
 
 
 
 

View 3 Replies View Related

CLR-Based Trigger? Recursive Trigger? Common Table Expression?

Nov 14, 2006

Hey,

I'm new to this whole SQL Server 2005 thing as well as database design and I've read up on various ways I can integrate business constraints into my database. I'm not sure which way applies to me, but I could use a helping hand in the right direction.

A quick explanation of the various tables I'm dealing with:
WBS - the Work Breakdown Structure, for example: A - Widget 1, AA - Widget 1 Subsystem 1, and etc.
Impacts - the Risk or Opportunity impacts for the weights of a part/assembly. (See Assemblies have Impacts below)
Allocations - the review of the product in question, say Widget 1, in terms of various weight totals, including all parts. Example - September allocation, Initial Demo allocation, etc. Mostly used for weight history and trending
Parts - There are hundreds of Parts which will eventually lead to thousands. Each part has a WBS element. [Seems redundant, but parts are managed in-house, and WBS elements are cross-company and issued by the Government]
Parts have Allocations - For weight history and trending (see Allocations). Example, Nut 17 can have a September 1st allocation, a September 5th allocation, etc.
Assemblies - Parts are assemblies by themselves and can belong to multiple assemblies. Now, there can be multiple parts on a product, say, an unmanned ground vehicle (UGV), and so those parts can belong to a higher "assembly" [For example, there can be 3 Nut 17's (lower assembly) on Widget 1 Subsystem 2 (higher assembly) and 4 more on Widget 1 Subsystem 5, etc.]. What I'm concerned about is ensuring that the weight roll-ups are accurate for all of the assemblies.
Assemblies have Impacts - There is a risk and opportunity impact setup modeled into this design to allow for a risk or opportunity to be marked on a per-assembly level. That's all this table represents.

A part is allocated a weight and then assigned to an assembly. The Assemblies table holds this hierarchical information - the lower assembly and the higher one, both of which are Parts entries in the [Parts have Allocations] table.

Therefore, to ensure proper weight roll ups in the [Parts have Allocations] table on a per part-basis, I would like to check for any inserts, updates, deletes on both the [Parts have Allocations] table as well as the [Assemblies] table and then re-calculate the weight roll up for every assembly. Now, I'm not sure if this is a huge performance hog, but I do need to keep all the information as up-to-date and as accurate as possible. As such, I'm not sure which method is even correct, although it seems an AFTER DML trigger is in order (from what I've gathered thus far). Keep in mind, this trigger needs to go through and check every WBS or Part and then go through and check all of it's associated assemblies and then ensure the weights are correct by re-summing the weights listed.

If you need the design or create script (table layout), please let me know.

Thanks.

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved