How to pass schema prefix to queries that don't contain it I have a bunch of SQL queries that don't have a schema prefix. Without the prefix, the queries won't run.
I wonder if there is a way to apply a schema to a query, without manually adding -- e.g., copying and pasting -- the schema prefix to each query. The prefix is the same for all the queries.
Also just to add, I use MS SQL Server. Thanks!
EDIT
I am adding a sample query as requested.
The queries are basically like
   USE   DBID1000

SELECT   T1.USERID
  FROM   TABLE1 AS T1 WITH (NOLOCK)
  JOIN   TABLE2 AS T2 ON T1.NAME = T2.NAME 

However, this won't run unless I add a schema prefix as shown below (assume the prefix is dbdbo
   USE   DBID1000

SELECT   T1.USERID
  FROM   dbdbo.TABLE1 AS T1 WITH (NOLOCK)
  JOIN   dbdbo.TABLE2 AS T2 ON T1.NAME = T2.NAME
Set the default schema for the user to the schema that your queries need to use.

ALTER USER [UserName] WITH DEFAULT_SCHEMA=[SchemaName]