Hi guys!
I need to create a table always that a new register is add in TABLE_ONE
The name of this new table must by 'TABLE_' + TABLE_ONE.Cod
It will be:
TABLE_1
TABLE_2
TABLE_3
...
I know this code must be in a trigger of insert... but how? I did some tests but didnt work.
Thanks in advance.What about this idea?
drop table test
go
create table test(id int identity, code varchar(10))
go
create trigger tr_test on test
for insert
as
declare @.sql varchar(8000)
set @.sql=''
select @.sql=@.sql+'create table '+code+'(id int identity)'+char(13)+char(10) from inserted
exec(@.sql)
go|||It Works.
Thank you.sql
No comments:
Post a Comment