zoukankan      html  css  js  c++  java
  • dhl:有用的sql语句(我用到的)更新中....

    1.复制表(包括数据):

    select * into vote.joinvotebak20100628 from vote.JoinVote

    2.只复制表结构(不复制数据)

    select * into vote.joinvotebak20100630 from vote.JoinVote where 1<>1

    3.复制指定数据到另一张表中

    declare  @startdate varchar(12)
    set @startdate = '05/07/2008'

    insert into  dbo.smsLog(pingcoid,mobile,[content],createtime)
    select  pingcoid,mobileId,'默认的数据',getdate() from pingco.dbo.TmobileInfo where convert(varchar(12), registerdate ,101) =@startdate

     两个服务器导数据:

    select * from cmsdata.[dbo].[CMS_WebConfig] --本地
    select * from wushuSVR.dudu837db.dbo.[CMS_WebConfig] --远程


    exec sp_addlinkedserver 'wushuSVR', '', 'SQLOLEDB', '113.11.*.*'
    exec sp_addlinkedsrvlogin 'wushuSVR', 'false',null, 'dudu', 'dudu837'

    --[CMS_WebConfig]
    insert into wushuSVR.dudu837db.dbo.[CMS_WebConfig](webtitle,keyword,copyright,memo,extended)
    select webtitle,keyword,copyright,memo,extended from cmsdata.[dbo].[CMS_WebConfig]

    4.表:

    declare @table table(id int identity(1,1),tid int) --创建表变量
    select * from @table

    create table #table (id int identity(1,1),tid int) --创建临时表
    select * from #table
    drop table #table   --删除临时表

    5.增加字段
    alter table docdsp  add dspcode char(200)
    删除字段
    ALTER TABLE table_NAME DROP COLUMN column_NAME
    修改字段类型
    ALTER TABLE table_name  ALTER COLUMN column_name new_data_type

  • 相关阅读:
    51.try块和catch块中return语句的执行
    17. 处理日期
    16.查找特定字符出现的次数
    15.字符串长度
    14.字符串拆分
    13.字符串比较
    12.幸运抽奖
    11.使用枚举
    10.获取系统时间
    MSSQL 判断临时表是否存在
  • 原文地址:https://www.cnblogs.com/dudu837/p/1768266.html
Copyright © 2011-2022 走看看