try something like

DECLARE @sSQL VarChar
DECLARE @crDataTable char(30)

SELECT @crDataTable = name
FROM sysobjects
WHERE xtype='U' AND name LIKE '[_]crData%'

SET @sSQL = 'DROP TABLE ' + @crDataTable
exec (@sSQL)

HTH

On 5/5/05, Jeff Chastain <[EMAIL PROTECTED]> wrote:
> Sorry for the off-topic, but I am having a bit of a query issue.  I have a
> dynamically created table that is named ' _crData123 ' where the 123 is some
> numeric identifier.  Now, I need to be able to drop this table.   The
> following query finds the table name and stores that name in a variable, but
> when I attempt to drop it via the variable, I get a syntax error.  Any
> suggestions on what is wrong with this or another way to do this in SQL
> Server?
> 
> ----------
> 
> DECLARE @crDataTable char(30)
> 
> SELECT @crDataTable = name
> FROM sysobjects
> WHERE xtype='U' AND name LIKE '[_]crData%'
> 
> DROP TABLE @crDataTable
> 
> ----------
> 
> Thanks
> -- Jeff
> 
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:205651
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to