This article introduces several methods for querying the database size in SQL.
This article introduces several methods for querying the database size in SQL.
First: (cricket)
The Code is as follows: |
|
Alter table tb (specify a column in a TABLE) Alter column colname nvarchar (100) COLLATE Chinese_PRC_CI_AS -- case insensitive Alter table tb (specify a column in a TABLE) Alter column colname nvarchar (100) COLLATE Chinese_PRC_CS_AS -- case sensitive Alter database COLLATE Chinese_PRC_CS_AS (specify the entire database) |
Type 2: (tree)
The Code is as follows: |
|
-- Create the following User-Defined Function (UDF) Create function StrComp (@ Str1 VARCHAR (50), @ Str2 VARCHAR (50 )) -- Alter function StrComp (@ Str1 VARCHAR (50), @ Str2 VARCHAR (50 )) RETURNS INTEGER AS BEGIN DECLARE @ I INTEGER -- DECLARE @ Str1 VARCHAR (50) -- DECLARE @ Str2 VARCHAR (50) DECLARE @ y INT -- SET @ Str1 = 'A' -- SET @ Str2 = 'A' SET @ I = 0 -- Select ascii (SUBSTRING (@ Str1, @ I + 1, 1 )) SET @ y = 1 DECLARE @ iLen INT SET @ iLen = LEN (LTRIM (RTRIM (@ Str1 ))) If len (LTRIM (RTRIM (@ Str1) <LEN (LTRIM (RTRIM (@ Str2) -- THEN SET @ iLen = LEN (LTRIM (RTRIM (@ Str2 ))) WHILE (@ I <@ iLen) BEGIN IF (ASCII (SUBSTRING (@ Str1, @ I + 1, 1) = ASCII (SUBSTRING (@ Str2, @ I + 1, 1) -- THEN SET @ I = @ I + 1 ELSE BEGIN SET @ y = 0 BREAK END END RETURN @ y END Test: Select * From Table1 Where dbo. StrComp (Field1, 'aabb ') = 1 |
Third: (Oliver)
Text Information in the SQL Server database can be stored with uppercase letters, lowercase letters, or a combination of the two. For example, the last name can appear in the form of "SMITH", "Smith", or "smith.
Whether the database is case sensitive depends on the Installation Method of SQL Server. If the database is case sensitive, you must use the correct combination of uppercase and lowercase letters to create search conditions when searching text data. For example, if you search for the name "Smith", you cannot use the search criteria "= smith" or "= SMITH ".
In addition, if the server is installed to be case-sensitive, the names of databases, owners, tables, and columns must be provided in a correct combination of uppercase and lowercase letters. If the provided name is case-insensitive, SQL Server Returns an error and reports "invalid object name ".
When you use the Relationship Diagram pane and grid pane to create a query, the query designer always correctly reflects whether the server is case sensitive. However, if you enter a query in the SQL pane, you must make sure that the name matches the server interpretation name.
If the server is installed with a case-insensitive option
Prompt to determine whether the server is case sensitive, execute the Stored Procedure sp_server_info and check the content of row 18th. If the server is installed with case-insensitive settings, the sort_order option is set to "case-insensitive ". You can run the stored procedure from the query analyzer.
Fourth: (non-cloud)
The Code is as follows: |
|
Select * from servers where convert (varbinary, name) = convert (varbinary, n'rockey ') |
Fifth :()
The Code is as follows: |
|
Ascii ('A') combined with Substring () |
Fifth,
The Code is as follows: |
|
SELECT DB_NAME (database_id) AS [Database Name], [Name] AS [Logical Name], [Physical_Name] AS [Physical Name] (size * 8)/1024) AS [Size (MB)], [differential_base_time] AS [Differential Base Time] FROM sys. master_files WHERE DB_NAME (database_id) IN ('xxx ') GO |