Query all databases
Select [name] from [sysdatabases] Order by [name]
Query all tables in a database
Select [ID], [name] from [sysobjects] Where [type] = 'U'
We all know that [type] = 'U' is a user table, and [type] = 's' is a system table.
Based on the query result of the previous statement
Query all the fields in a table (I tried to query the fields using [name] instead of [ID]. An error is returned)
Select [name] from [syscolumns] Where [ID] = 1931153925
The preceding statements are used to query all tables:
Change the architecture of all tables as follows:
Architecture A and user a exist in the Database testdb. Now, the user of the database testdb is changed from A to B, and user a is deleted. The architecture is also changed from A to B, and schema A is deleted, the procedure is as follows:
1. create user B and then create architecture B;
2. Grant schema A permissions to user B, cancel user a's permissions on schema A, and delete user;
3. Change all database objects belonging to architecture a to architecture B. The Code is as follows:
Alter schema [new schema name] Old transfer schema name. [object table or view or stored procedure in the database]
Alter schema [B] transfer A. [object 1]
Alter schema [B] transfer A. [object 2]
Alter schema [B] transfer A. [object N]
4. Delete architecture.
For example, alter schema DBO transfer danxiao1.ds _ city1