Quantcast
Channel: Forum SQL Server Database Engine
Viewing all articles
Browse latest Browse all 15889

How can we rollback alter user statement

$
0
0

Hi All,

We have a requirement of changing schemas but it we also need it to revert to the original one.

Alter user <user> with default_schema = <newSchema> does the job of changing the schema.But found that this change is done at the database level and is permanent.Meaning if I change the schema for a user in one connection then it remains the same even after the connection closes and user connects again using a different connection.

We do only read operations after altering a schema so I thought of rolling back the transaction once we change the schema and the query has been executed so that it reverts to original schema.Something like this -->

begin transaction

Alter user <user> with default_schema = <newSchema>;

select * from <tableName>;

rollback transaction

But noticed that rollback does not have any effect.The schema name remains as <newSchema>.

Is there any way of changing the schema just for that particular connection and then revert ?


Viewing all articles
Browse latest Browse all 15889

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>