I'm creating a user specific table in my database. The table name will have the format
[dbo].[tablename_user1]
So the table will have variable names.
I'm trying to adapt the drop table statement (below) so that it will handle this variable table name.
if exists (select * from sysobjects where id = object_id(N'[dbo].[tblImportNCHRedemption]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[tblImportNCHRedemption]
I'm failing miserably.
I've tried seting two variables (@tablename) and (@SQL). I've been using these variables to write some code along the lines of
Set @SQL = 'If exsists etc. ' + @tablename + ' etc...
Execute(@SQL)
The problem is that the ' marks get all in a mix and messy
Please help
[dbo].[tablename_user1]
So the table will have variable names.
I'm trying to adapt the drop table statement (below) so that it will handle this variable table name.
if exists (select * from sysobjects where id = object_id(N'[dbo].[tblImportNCHRedemption]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[tblImportNCHRedemption]
I'm failing miserably.
I've tried seting two variables (@tablename) and (@SQL). I've been using these variables to write some code along the lines of
Set @SQL = 'If exsists etc. ' + @tablename + ' etc...
Execute(@SQL)
The problem is that the ' marks get all in a mix and messy
Please help