20101023 学习记录:复制表 vs 操作数据库的VBScript


复制表AA到BB,包括表结构和数据:

select * into  tmp.dbo.BB  from xxx.dbo.AA

 


复制表AA到BB,只复制表结构,不复制数据:

select * into  tmp.dbo.BB  from xxx.dbo.AA  WHERE 1=2 

 

 

已有表结构,复制记录:
insert into tmp.dbo.BB select * from xxx.dbo.AA
  


 

Dim ConnectionString' As String
Dim strQuery 'As String
Dim strCondition 'As Integer

Set Conn=CreateObject("ADODB.Connection")
Conn.ConnectionString = "Provider=SQLOLEDB.1;Password=xxxxx;Persist Security Info=True;User ID=sa;Initial Catalog=tmp;Data Source=s01"
strCondition ="aaa"

strQuery = "INSERT INTO tmp.dbo.test2  select * from tmp.dbo.test1 where tmp.dbo.test1.iso2 = '" & strCondition & "' ; delete tmp.dbo.test1 where tmp.dbo.test1.iso2 = '" & strCondition& "' "
Conn.open
Conn.Execute strQuery   
Conn.Close 

 

 

你可能感兴趣的:(VBScript)