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.
Often encountered some forget the table name situation, at this time only remember a approximate, at this time can be queried by the system table sysobjects to find the table name, such as to find the name of the table containing the user, can be implemented by the following SQL
Tags: div LSE blog Information upd ROM targe com serveTransferred from: http://www.maomao365.com/?p=6973 Summary:In SQL scripting, if you need to use the method of table aliases in update Delete, you must write according to certain rules, otherwise the corresponding exception information will appear as follows:Lab environment:
Label:To modify the table design of a database, you can use the SQL ALTER TABLE statement, which is used to add, delete, or modify table columns in an existing table. 1> add a new column to the database table:Grammar:ALTER
Tags: img Handy inner code insert with run while extraSometimes we want to know by a value which table and which field from the database, search on the Internet, find a better way to achieve through a stored procedure. Just pass in a value that you want to find, and you can query the table and field name where the value resides. The premise is to put this stored procedure in the database you are querying. N
[a basket of rice special thin Original, reproduced please indicate from http://www.cnblogs.com/wanghafan/p/4384039.html]Prerequisites: Two tables to update the field, the associated field structure is consistentUpdate Library: FJPDI_TZGLExtract Library: fjpdi_tzgl_29Table: DatachangestemptUpdate field: REASONAssociated field: IIDGoal: Update the datachangestempt reason field in fjpdi_tzgl_29 to datachanges
/*
@ Errorcode 0 success
@ Errorcode-1 failure rolled back
*/
Declare @ errorcode int
Set @ errorcode = 0
Declare @ transtarted bit
Set @ transtarted = 0
If (@ trancount = 0)
Begin
Begin transaction
Set @ transtarted = 1
End
Else
Set @ transtarted = 0
-- Update, delete, and insert a table (omitted)
If (@ error
Begin
Set @ errorcode =-1
Goto cleanup
End
-- Update
SQL SERVER Determines if there is a database, table, column, view--1. Determine if the database existsIF EXISTS(SELECT * fromSYS. DATABASESWHERENAME= 'Database name') DROP DATABASE [Database name] --2. Determine if a table existsIF EXISTS(SELECT * fromSYSOBJECTSWHEREId= object_id(N'[
Environment: SQL Server 2008 R2
Problem: Modifying table column names
Solve:
Modify the table's column name in SQL Server to invoke the stored procedure sp_rename.
Use test;--using the database
sp_rename ' D_s_t.avg_grade ', ' avg_g ', '
A method of SQL Update multi-table joint updating
You can modify the field values of one table and the other table associations based on the values of one table's fields, like an associated queryUpdate table one set
Original: SQL Server determines if there is a database, table, column, view1 determining whether a database existsif exists (SELECT * from sys.databases WHERE name = ' database name ')drop database [DB name]2 Determining whether a table existsif exists (select * from sysobjects where id = object_id (n ' [
Label: About the "Unable to create a linked server"(NULL)"This error may be reported when the OLE DB provider SQL Server 2008 reads Excel data: Unable to create linked server"(NULL)"The OLE DB Access interface"MSDASC"the instance. 1This error occurs primarily when reading data with code: INSERT into database table nameSelect* fromOpenDataSource ('microsoft.ace.oledb.12.0','Data source= "d:\Excel
deal with them now:The first step is to add the field GUID to the new table and prepare the associated data.ALTER TABLE dbo. TABLE Add GUID char (38)ALTER TABLE dbo. Table_sub Add GUID char (38)The GUID in the table_sub is the old_table_sub old_table_guid);Everyone should have understood it.The second step is to copy
1. Create a test tableCreate table t_user (ID int identity primary key,UserID varchar (50) not null,UserName varchar (50) null,DeptID int not null,Phone varchar (50) null,Fax varchar (50) null)
Create table t_dept (ID int identity primary key,DeptName varchar (50) null,Phone varchar (50) null,Fax varchar (50) null)
INSERT t_userSelect n '001', N 'zhang san', 1, N '000000', N '000000'UNIONAll select n '002 '
Label:
In our development process, it is unavoidable to encounter a scene, the value of a column in a table is stitched into a comma-separated row of data
We're stitching up the UserID column into a row of data
-------》
So I wrote a stored procedure to solve this kind of problem.
--AUTHOR:LHM--Create date:2015-01-15
--Description: A
Product (pid, name, amount, nowAmount): ID, name, existing quantity, current quantityTrade (id, pid, operType, number): identifier, product identifier, operation type (warehouse receiving: 1, warehouse picking: 0), quantity
Test data in the Product table:
1
Apple
100
0
2
Orange
50
0
Test data in the Trade table:
1
1
1
432
2
1
0
50
Tags: ring using har cell storage traints Batch ref ACERecently modified the database table structure, the data synchronization problem, found that a lot of data has been modified, but filtered through the view or the original data, so suspect should be the view cache data, in the garden to find the following blog post, here to make a record memo. original link:http://www.cnblogs.com/yashen/archive/2004/12/23/81000.html This is often the case when w
SQL statement query table name/column name/primary key/Auto grow value in database
----A table created by a user in a query database
----JSJ01 as database name
Select name tablename from JSJ01. sysobjects where type= ' U ' and name not in (' dtproperties ')
--field information in the query
To determine whether a table exists:Grammar:SELECT * FROM dbo. SysObjects WHERE id = object_id (N ' table name ') Example:SELECT * FROM dbo. SysObjects WHERE id = object_id (N ' Exchangelog ')if exists (SELECT * FROM dbo. SysObjects WHERE id = object_id (N ' Exchangelog ')) print ' table exists ' else print ' table
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.