• Add a column with default current date time
    ALTER TABLE [TableName]
    ADD CreatedOn DATETIME NOT NULL DEFAULT(GETDATE());
  • How to Quickly Create a Copy of a Table using Transact-SQL 
    The easiest way to create a copy of a table is to use a Transact-SQL command. Use SELECT INTO to extract all the rows from an existing table into the new table. The new table must not exist already. The following example will copy the Customers table under the Sales schema to a new table calledCurrCustomers under the BizDev schema:
    SELECT * INTO BizDev.CurrCustomers FROM Sales.Customers
    You can also create the new table from a specific subset of columns in the original table. In this case, you specify the names of the columns to copy after the SELECT keyword. Any columns not specified are excluded from the new table. The following example copies specific columns to a new table:
    SELECT CustName, Address, Telephone, Email INTO BizDev.CurrCustomers
    FROM Sales.Customers
  • Rename database
    ALTER DATABASE [CurrentDatabaseName]
    Modify Name = [NewDatabaseName]

SQL scripts的更多相关文章

  1. [MSSQL] Useful SQL Scripts - CalendarBase

    Useful SQL scripts DECLARE @StartDate DATETIME DECLARE @EndDate DATETIME DECLARE @FiscalBeginMonth I ...

  2. General Ledger Useful SQL Scripts – Oracle Applications 11i

    General Ledger Useful SQL Scripts – Oracle Applications 11i Contents GL Set of Books Configuration O ...

  3. General Ledger Useful SQL Scripts

    General Ledger Useful SQL Scripts – Oracle Applications 11i Contents GL Set of Books Configuration O ...

  4. 读书笔记--SQL必知必会--建立练习环境

    书目信息 中文名:<SQL必知必会(第4版)> 英文名:<Sams Teach Yourself SQL in 10 Minutes - Fourth Edition> MyS ...

  5. 初试WIX加SQL LocalDB

    最近有个项目需要生成一个自动打包安装App和数据库的MSI文件,经同事推荐WIX,于是乎就试了一试.遇到了一些问题觉得有分享的价值,所以写篇博客记录一下 :) 使用感觉: WIX特点:功能很强大,用X ...

  6. [转]Dynamic SQL & Stored Procedure Usage in T-SQL

    转自:http://www.sqlusa.com/bestpractices/training/scripts/dynamicsql/ Dynamic SQL & Stored Procedu ...

  7. Security Configuration and Auditing Scripts for Oracle E-Business Suite (文档 ID 2069190.1)

    This document provides the security configuration and auditing scripts for Oracle E-Business Suite. ...

  8. P6 Professional Installation and Configuration Guide (Microsoft SQL Server Database) 16 R1

    P6 Professional Installation and Configuration Guide (Microsoft SQL Server Database) 16 R1       May ...

  9. Database SQL script automation management tools investigation

    Recently researched about database SQL scripts auto management tools, recorded the results here. Res ...

随机推荐

  1. ACM: hdu 1811 Rank of Tetris - 拓扑排序-并查集-离线

    hdu 1811 Rank of Tetris Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & % ...

  2. Java中集合Set的用法

    转载 http://blog.163.com/asd_wll/blog/static/210310402010112833332260/ 1.HashSet类 Java.util.HashSet类实现 ...

  3. Linux之进程管理

    ==================================================================================================== ...

  4. BZOJ4454: C Language Practice

    Description Input 第一行输入一个正整数T(T<=85),表示测试数据的组数. 每组数据第一行包含两个正整数n,m(1<=n,m<=2000),表示序列的长度. 第二 ...

  5. C# 窗体位置 Show和ShowDialog(转)

    CenterParent 窗体在其父窗体中居中. CenterScreen 窗体在当前显示窗口中居中,其尺寸在窗体大小中指定. Manual 窗体的位置由 Location 属性确定. Windows ...

  6. IDictionary<TKey, TValue> vs. IDictionary

    Enumerating directly over an IDictionary<TKey,TValue>returns a sequence of  KeyValuePair struc ...

  7. js判断三个数字中的最大值

    <script> //方法一: function maxOf3(c,d,e){ return (((c>d)?c:d)>e ? ((c>d)?c:d) : e); } c ...

  8. pthread_creat()解析及需注意的地方

    函数声明 int pthread_create(pthread_t*restrict tidp,const pthread_attr_t *restrict_attr,void*(*start_rtn ...

  9. hao123列表的实现

    <!DOCTYPE html><html><head>        <meta http-equiv="Content-Type" co ...

  10. scala - Map基础

    Map 构造Map 不可变: val map = Map("sa" -> 1, "s" -> 2)map("sa") = 3 / ...