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

相关文章:

  • 2021-06-28
  • 2022-12-23
  • 2022-02-13
  • 2022-02-13
  • 2021-06-04
  • 2021-05-19
猜你喜欢
  • 2021-10-19
  • 2021-11-08
  • 2021-12-10
  • 2021-06-17
  • 2021-12-12
  • 2021-06-24
  • 2021-11-18
相关资源
相似解决方案