Querying all the Databases
Select [Name] from [sysdatabases] ORDER by [name]
Querying for all tables in a database
Select [ID], [name] from [sysobjects] where [type] = ' u '
all know [Type] = ' u ' is the user table, [type] = ' s ' is the system table.
Based on the query results from the previous statement, and then
Query all the fields in a table (I try to use [name] instead of [ID] and the results are wrong)
Select [Name] from [syscolumns] where [id] = 1931153925
All tables are queried:
Here's how to change all table schemas:
Schema A and user A are present in the database TestDB, the user who owns the TestDB database is changed from a to B, the user A is deleted, the schema is changed from a to B, the schema A is deleted, and the operation is as follows:
1, create User B, and then create schema B;
2. Assign the permissions of schema A to User B, cancel user A's permission to have schema A, delete User A;
3. Change all objects belonging to schema A of the database to schema B with the following code:
ALTER schema [new schema name] TRANSFER the old schema name. [Object table or view or stored procedure in database]
ALTER SCHEMA [B] TRANSFER a.[Object 1]
ALTER SCHEMA [B] TRANSFER a.[Object 2]
ALTER SCHEMA [B] TRANSFER a.[object N]
4, delete the schema A.
Such as:
ALTER SCHEMA dbo TRANSFER danxiao1.ds_city1