Home > database >  Great god taught: SQL database when the contents of one table to add a data write a trigger to make
Great god taught: SQL database when the contents of one table to add a data write a trigger to make

Time:04-28

SQL database when the content of the table to add a write a trigger to make it automatic generating but the name of the table to automatically generate a table needed is to add the table in a field such as the content of the table name need to automatically generate a member of the table name is to that person

CodePudding user response:

This is to do the main table list... Don't bother each corresponding to a new table, then the master record

CodePudding user response:

 

CodePudding user response:

This line can build dynamic SQL to achieve, you can follow this
 
Declare @ person nvarchar (10)
Select @ person=the person from the test where id=17
Print @ person
Declare @ nSQL nvarchar (200)
The set @ nSQL='create table' + @ person + '(
SNO char (2) not null,
SN char (8) not null,
SEX char (2),
The AGE tinyint,
DEPT char (10)
) '
The exec (@ nSQL)
  • Related