joss22
When you build @myList , do you return SUM().. or sopme another
aggregation result?
SELECT SUM(col) AS mycolname
BTW, be aware of SQL Injections while you build dynamic sql in that way
>I have build a trigger for insert, update and delete that works with
> all the fields of a table, it doesn't matter the names and the number
[quoted text clipped - 17 lines]
>
> Any help, please?
joss22 - 29 Apr 2008 08:43 GMT
Nop. I'm using this procedure to load this variable:
********* PROCEDURE ***********
CREATE PROCEDURE getColumnList @table varchar(255), @columns
varchar(1000) OUTPUT
AS
DECLARE @CONTENIDO AS VARCHAR(250)
set @contenido=''
SELECT @content=@content+column_name+','
FROM [MYBD].[INFORMATION_SCHEMA].[COLUMNS]
WHERE TABLE_name = @table and data_type not in
('ntext','text','image')
select @columnas = SUBSTRING(@contenido,1,LEN(@contenido)-1)
GO
********* END PROCEDURE ***********
And then I use it on my trigger this way:
exec getColumnList 'MYTABLE' , @listaCampos output
and @listaCampos is 'field1,field2,field3,field4'
> joss22
> When you build @myList , do you return SUM().. or sopme another
[quoted text clipped - 25 lines]
>
> > Any help, please?
EXEC of dynamic SQL creates a new context that does not have access to
the INSERTED or DELETED tables. Only code written directly into the
trigger can see those tables.
Roy Harvey
Beacon Falls, CT
>I have build a trigger for insert, update and delete that works with
>all the fields of a table, it doesn't matter the names and the number
[quoted text clipped - 17 lines]
>
>Any help, please?
joss22 - 30 Apr 2008 08:44 GMT
Thanks Ron. I've solved the problem just changing those text and ntext
fields to varchar(MAX) and nvarchar(max)
On 29 abr, 13:27, "Roy Harvey (SQL Server MVP)" <roy_har...@snet.net>
wrote:
> EXEC of dynamic SQL creates a new context that does not have access to
> the INSERTED or DELETED tables. Only code written directly into the
[quoted text clipped - 24 lines]
>
> >Any help, please?