Alibabacloud.com offers a wide variety of articles about update column from another table sql, easily find your update column from another table sql information here online.
If you want to change the name of the table column as required, you usually choose server-database-table from isisemanager and modify the table. This is too troublesome. You can use the script to check it.
To change the name of the table
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
The database has two fields in the wrong position, you want to change them. Because there is no database write permission, it needs to be implemented with SQL statements. Originally thought to be simpleUpdate table A set a. Field a= (select B field from table where id=?), set a. Field b= (Select a field from table wher
It mainly uses case statements to solve the problem of Row-to-column conversion.The row-to-column conversion problem is mainly divided into two types:
1) Simple row-to-column conversion:
Example Table:
Id Sid Course Result
1 2005001 Chinese 80.02 2005001 mathematics 90.03 2005001 English 80.04 2005002 Chinese 56.020050
Tags: style http color io strong for AR artAdd a table fieldALTER TABLE table1 add transactor varchar (ten) not Null;ALTER TABLE table1 add ID int unsigned not Null auto_increment primary keyModify the field type of a table and specify empty or non-emptyALTER TABLE name chan
* From sysindexkeys-- Each index and table in the database occupies one row in the table.-- Sysindexkeys. ID table ID-- Sysindexkeys. indid index ID type-- Sysindexkeys. colid column ID
The primary key must be a unique index. The unique index is not necessarily a primary key.
A primary key uniquely identifies a ro
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
I. Requirements
1. Create a data table
Create Table [DBO]. [stuscore] (
[Stuid] [int] not null,
[Subject] [nvarchar] (30) null,
[Score] [decimal] (5, 1) null
)
2. Insert Test Data
Stuid subject score
3 Chinese 76.0
3 math 73.0
4 Chinese 82.0
5 Chinese 66.0
5 math 93.0
6 Chinese 67.0
7 math 83.0
8 Chinese 77.0
8 math 84.0
Result After three rows are converted into columns
Stuid Chinese math
3 76.0 73.0
4 8
Tags: plsql developer text EditingOriginal works, from the "Blue Blog" blog, Welcome to reprint, please be sure to indicate the following sources, otherwise, the legal responsibility to pursue copyright.Deep Blue Blog:http://blog.csdn.net/huangyanlong/article/details/41513537Experiment: Use PL/SQL developer software to get the text form of table name and column n
Tags: --sql Server 2005, or 2012:select * from Information_schema.tables--sql server 2000:select * from sysobjects WHERE xt ype= ' u ' select * from sysobjects WHERE xtype= ' u ' select table_name from GEOVIDNU. Information_schema. Tablesselect sobjects.namefrom sysobjects sobjectswhere sobjects.xtype = ' U ' EXEC sp_spaceused ' yourtablename '-- The column name
For example, if a table is like this, the ID is the primary key and the table is auto-incrementing:
Column name: Id Columna columnb columnc
Column value: 1 A asdfd afdsf
2 B sdfafsd 080dfs
3 A dfsafja08 90879.
4 C fds934 fsdaf
5 B safsfsd fd86fsdaf
The query results after the SQL
xtype= ' PK ') Alter TABLE stuinfo Drop Constraint Pk_stuno Go--Re-add PRIMARY KEY constraint Pk_stuno ALTER TABLE stuinfo add CONSTRAINT pk_stuno PRIMARY key (Stuno) Go--Example 3 adds a unique UQ constraint (unique CONSTRAINT)--exists only A constraint Uq_stuno, delete the IF EXISTS (SELECT * from sysobjects WHERE name= ' uq_stuid ' and xtype= ' UQ ') Alter TABLE
) VALUES (' Xiao Wang ', ' C # Advanced programming ', 8); INSERT into S (name,book,salednumber) values (' Xiao Li ', ' Java from beginner to proficient ', 7); INSERT into S (name,book,salednumber) VALUES (' Xiao Wang ', ' Java from beginner to proficient ', 9); INSERT into S (name,book,salednumber Values (' Xiao Li ', ' Java from beginner to proficient ', 2); INSERT into S (name,book,salednumber) VALUES (' Xiao Wang ', ' C # Advanced Programming ', 3); INSERT into S (Name,book, Salednumber) VAL
The method used to determine whether a table or column does not exist in SQL Server.
1. How to determine whether a Column exists in the Table in SQL Server
First, I would like to share with you two methods for determining whether
A few days ago, my colleague asked me how to convert a field value to a column. I wrote a simple Demo to share it. The Code is as follows: -- create a test table and add Test Data createtable # temp (amoney, bvarchar (10) * insertinto # temp (a, B) values () insert
A few days ago, a colleague asked me how to convert a field value to a column. I wrote a simple Dem
The code is as follows:
EXEC sp_rename ' table name. [Original column name] ', ' new column name ', ' column '
Transact-SQL Reference
sp_rename
Changes the name of a user-created object (such as a table,
'))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
Tags: style http color io strong for AR Art Div www.169it.comAdd a table fieldALTER TABLE table1 add transactor varchar (ten) not Null;ALTER TABLE table1 add ID int unsigned not Null auto_increment primary keyModify the field type of a table and specify empty or
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.