Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
NaseemAfzal
Starting Member
2 Posts |
Posted - 2014-05-20 : 18:13:01
|
Am new to SQL server , I have created the below procedure to create a table dynamicallyALTER PROC [dbo].[createLogTrigger]( @TableName VARCHAR(100))ASDECLARE@SQLTRIG VARCHAR(4000),@SQLLOGT nVARCHAR(4000);BEGIN SELECT SQLLOGT= ' CREATE TABLE ' +@TableName + '_AUDIT ( Audit_id [int] IDENTITY(1,1) NOT NULL, ' + @TableName+'_id [int] NOT NULL , change_type varchar(10) NOT NULL, Column_name varchar(100) , old_value varchar(400), new_value varchar(400), UserName varchar(20) NOT NULL, UpdateDate varchar(21) NOT NULL)' PRINT @SQLLOGT EXEC sp_executesql @SQLLOGTENDThe procedure executes fine but table is not getting created. Please help me solving thisThanks, |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2014-05-20 : 19:43:23
|
Oh I see the issue: SELECT SQLLOGT ==> SELECT @SQLLOGTTara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
NaseemAfzal
Starting Member
2 Posts |
Posted - 2014-05-21 : 11:09:40
|
Thanks Tara Kizer!Its my bad, I didn't notice. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|
|