all groups > sql server (alternate) > september 2006 >
You're in the

sql server (alternate)

group:

Using USER value in SQL code


Using USER value in SQL code billharrison9 NO[at]SPAM gmail.com
9/21/2006 12:43:33 PM
sql server (alternate):
I need to be able to drop a table after a user is done with it. I have
tried something like,

DROP TABLE USER.tblEducation_SAP1

but I get an error.

Can someone suggest the way I should be using the USER value in this
instance?

Thanks!
Re: Using USER value in SQL code Erland Sommarskog
9/21/2006 9:53:23 PM
(billharrison9@gmail.com) writes:
[quoted text, click to view]

And the error message is? Of course, if that is the exact command line
you would get a syntax error since USER is a reserved word in T-SQL. But
I don't know whether that USER is just a place holder.

[quoted text, click to view]

You could use dynamic SQL. Then again, if you are on SQL 2000 you could
just say

DROP TABLE tblEducation_SAP1

since the default schema for a user always agrees with the name of the
user. (This is a little different on SQL 2005 where users and schema
are separate.)


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
AddThis Social Bookmark Button