Scripts for several SQL languages

Source: Internet
Author: User

To add a field to a specific table in a particular database:
to add a field to a specific table in a particular database:ALTER TABLE Test1.dbo.test1 Add "name9" int must be careful to add type
2 adding data from one table to another table update test.dbo.test//Database Set test.sex = xx.sex//write field value from (select Id,sex from test1.db O.TEST1) as XX//Added condition where xx.id=test.id//3 runs SQL statement 1 on the command line. Sqlcmd-e-dmaster–i followed by file address pause 2. Create a. bat file under C to write a statement. Click to run the SQL program. 3 Create a table: Use Ftest3create table Sysnavy (navy_id varchar (a) NOT NULL primary key,navy_name varchar (), Navy_lev varchar (a), navy_parent_id varchar (+), Create_name varchar (+), Create_time varchar (+), Update_name varchar (+), Update_ Time varchar, Navy_url varchar (+), Navy_sort int) 4 Add the data from the original table to the newly created table: INSERT INTO Ftest3.dbo.test (Navy_id,navy_name, Navy_parent_id,create_man,create_time,navy_sort,navy_url,navy_lev,update_man,update_time) Select Navy_id,A.navy_ Name,navy_parent_id,create_man,create_time,navy_sort,navy_url,navy_lev,update_man,update_time from Test2.dbo.testas awhere nnavy_id!= (select navy_id from ftest3.dbo.test)//Here is how the conditional statement is implemented this is the table data that has the same table name in different data

  

Scripting for several SQL languages

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.