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 |
|
Hienzs
Starting Member
8 Posts |
Posted - 2007-01-24 : 14:51:34
|
HiI am trying to use sql injection to create a dynamic drop table statment. I have tried to reformat a bunch of ways but can not get it. What am I doing wrong?set @sql = 'if exists (select * from dbo.sysobjects where id = object_id(N' + @@tblname + ') and OBJECTPROPERTY(id, N' + 'IsUserTable' + ') = 1)'drop table @@tblnameexecute(@sql) |
|
|
snSQL
Master Smack Fu Yak Hacker
1837 Posts |
Posted - 2007-01-24 : 15:04:32
|
| [code]declare @tblname varchar(200), @sql varchar(4000)set @tblname = 'a_table'set @sql = 'if exists (select * from dbo.sysobjects where id = object_id(N''' + @tblname + ''') and OBJECTPROPERTY(id, N''IsUserTable'') = 1)' + ' drop table ' + @tblnameexecute(@sql)[/code] |
 |
|
|
Hienzs
Starting Member
8 Posts |
Posted - 2007-01-24 : 15:07:20
|
| Thanks. works like a charm. I should have asked you guys sooner. Wasted a lot of time trying to figure it out. |
 |
|
|
|
|
|