The Code is as follows:
EXEC sp_rename 'table name. [original column name] ', 'new column name', 'column'
Transact-SQL referenceSp_renameChange the name of the user-created object (such as a table, column, or user-defined data type) in the current database.
Syntax
Sp_rename
ProblemI have a table where some of the columns should is queryable by all users. How can I filter the data appropriately so and not everyone can select the data? In a previous tip, the Filtering Columns in SQL Server with the using views we looked at the using views. In this tip we cover the can is done with Column-level permissions.SolutionOne of the easiest ways to does this is through. However, if that
: delimiter CREATE PROCEDURE sp_count () BEGIN #课程名称 DECLARE course_n VARCHAR (20); #所有课程数量 DECLARE Count INT; #计数器 DECLARE i INT DEFAULT 0; #拼接SQL字符串 SET @s = ' SELECT name '; SET count = (SELECT count (distinct course) from grade); While I Method Analysis:The first method uses table joins.The second uses a grouping, which is processed separately for each grouping.The third uses the stored procedure, is actually the second method dynamic, first calc
Some records may be deleted when we use the database. Therefore, the identifiers in the data table may not start from 1 or intermittently. How can we reset and arrange it?
SQL Server IDs are often used to increase by itself, that is, the identification column to act as the primary key of a table.
There are two concepts to be clarified:
1. ID column:Use the identity attribute to create an applicationPr
Label:Pivot and Unpivot can be used in Ms-sqlserver 2005 and Oracle for Row and column conversions, but dynamic columns are not supported. Here, the case and then else end statements are used to implement the row and column conversions. How to implement dynamic columns at the bottom. Below is an example of a Student score table: ID Name Account Score 1 in three languages 602 Zhang Three Mathematics 653 Thre
Table-level constraints and column-level constraints in SQL, in SQL Server, (1) The constraint of the base table is divided into column and table constraints constraints are the range of values that restrict the data entered into the table by the user, generally divided into colum
However, Microsoft SQL server has an important defect in processing such indexes, that is, the operations that should have been compiled into index seek are compiled into index scanning, which may cause serious performance degradation.
For example, assume that a table T has an index (cityid, sentdate, userid) and now has a paging list function, to query several records greater than a certain multi-Column C
[Mysql] The SQL _mode configuration associated with Data truncated for column, truncatedsql_mode
System Logs
Ata truncated for column 'agent' at row 1
The reason for this problem in mysql is nothing more than Character Set setting or a too long field.Mysql has been unified into UTF-8 during initialization, so you can ignore this problem.
If the string is too lon
Concatenate multiple rows of records in the same column in Oracle into a string [SQL] -- raw data -- a 111 -- B 222 -- a 333 -- a 444 -- B 555 -- final result -- a 111*333*444 SELECT L4.L _ TIME, MAX (SUBSTR (L4. group CONTENT, 2) final field value FROM (SELECT L3.L _ TIME, SYS_CONNECT_BY_PATH (L3.L _ CONTENT ,'*') AS group content from (SELECT L2.L _ TIME, L2.L _ CONTENT, L2.L _ TIME | L2. group id as grou
When using a stored procedure, you can use dynamic SQL when dynamically passing the table name or column name.CodeAs follows;
Alter procedure proc_updatedatetimecounter
@ Businessnum nvarchar (
200 ), -- Business number
@ Column nvarchar (
200 ), -- Column name
@ Value
Because in the SQL-SERVER, the auto-incrementing column property cannot be directly modified, but you can achieve it through the following method:
1. If you only insert a specified value, use the following statement to temporarily cancel the operation.
Set identity_insert tablename onInsert into tablename (XX, XX) values (XX, XX)Set identity_insert tablename off
2. Add a
'))Drop function [dbo]. [function name]7 getting user-created object informationSELECT [name],[id],crdate from sysobjects where xtype= ' U '8 determining whether a column existsif exists (SELECT * from syscolumns where id=object_id (' table name ') and name= ' column name ')ALTER TABLE table name drop column name9 Jud
Introduction
T-SQL is not just a language for querying a database, or a language that can manipulate data. Column-based case expressions are one of them, unlike other query statements that can be substituted for each other (for example, queries implemented with subqueries can also be implemented by joins), and case expressions are largely irreplaceable in the control of columns based logic. The case expres
Grammar:Pivot is used to rotate column values to column names (row to column), which can be implemented in SQL Server in conjunction with a case statement with an aggregate function the general syntax for pivot is:pivot( aggregate function (column) for
How to determine the maximum value in the SQL Server Column
Create table [dbo]. [MinMax] (
[MinMaxID] [int] IDENTITY (1, 1) not null,
[Value1] [int] NULL,
[Value2] [int] NULL,
[Value3] [int] NULL,
[Value4] [int]
A simple SQL row and column conversion
Author:eaglet
In database development, we often encounter the problem of row and column conversion, such as the following question, department, employee and employee type three sheets, we want to count similar list
Department Number department name total formal staff temporary staff dismiss staff
1 A 30 20 10 1
This problem
adding the course. And the third one doesn't have that kind of problem. Note: MySQL cannot remove another stored procedure in one stored procedure, only another stored procedure can be calledOriginally wanted to write in method three: DROP PROCEDURE IF EXISTS sp_count (); This is wrong. Debugging when the wrong write, can only be manually deleted, and did not find a good method. References:
Relive sql--row to
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.