Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Function To Test For Table Doesn't Work
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
01328338
Message ID:
01328481
Views:
8
Sergey,

It's working. The table is being dropped, however the message
"Database name 'tempdb' ignored, referencing object in tempdb"
appears in the results pane each time I run it.




>You have to prefix a temp table with 'temdb..' as I shown in my original post. Try this one
>
>ALTER FUNCTION dbo.fnTableExists
>	(@sTableName VARCHAR(50))
>
>RETURNS TinyInt
>AS
>
>BEGIN
>	IF @sTableName LIKE '#%'
>		SET @sTableName = 'tempdb..' + @sTableName
>
>	RETURN CASE WHEN object_id(@sTableName) IS NOT NULL THEN 1 ELSE 0 END
>
>END
>
>
>
>>
>>I could use your expertise here. This just isn't working:
>>
>>
>>DROP TABLE #temp
>>
>>CREATE TABLE #temp (ch CHAR(1))
>>
>>DECLARE @sTableName VARCHAR(MAX)
>>SET @sTableName = '#temp'
>>
>>
>>IF object_Id(@sTableName)is not null
>>	EXEC('DROP TABLE ' + @sTableName)
>>
>>CREATE TABLE #temp (ch CHAR(1))
>>
>>
>>Any idea what I'm doing wrong here?
>>
>>
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform