同意楼上兄弟,使用 select * into newtable from table where 1=2 可以复制一个表,根据where条件,可以复制有不同记录的表
生成SQL语句 用 Public Function Creat_Table(data As String, Files As String) As Boolean '本模块用于从*.sql中导入数据库结构到SQL Server Dim SQL, Txtline As String On Error Resume Next Cn.Close On Error GoTo Err1 ConSQL Load_ini("服务器名"), Load_ini("用户名"), Load_ini("口令"), data, "Cn" SQL = " " Open App.Path & "\log.txt" For Output As #2 ' 打开输出文件。 ' 将错误数据写入文件。 Open App.Path & Files For Input As #1 ' 打开SQL文件。 Do While Not EOF(1) Line Input #1, Textline If Not (Trim(Textline) = "GO") Then SQL = SQL & Textline & Chr(13) Else Cn.Execute SQL 'Mid(SQL, InStr(SQL, "C")) SQL = " " End If Loop Close #1 Close #2 'If Creat_Table = False Then ' Shell App.Path & "\log.txt" 'End If
Exit Function Err1: Print #2, "This is a Error !" Print #2, Err.Description Print #2, Err.Number Print #2, "**********" Creat_Table = False Resume Next End Function
_1_(到jinesc.6600.org来找我) :我用的不是SQL SERVER 我用的是ACCESS
可能是这个
select * into newtable from table where 1=2
可以复制一个表,根据where条件,可以复制有不同记录的表
用 Public Function Creat_Table(data As String, Files As String) As Boolean
'本模块用于从*.sql中导入数据库结构到SQL Server
Dim SQL, Txtline As String On Error Resume Next
Cn.Close
On Error GoTo Err1
ConSQL Load_ini("服务器名"), Load_ini("用户名"), Load_ini("口令"), data, "Cn"
SQL = " "
Open App.Path & "\log.txt" For Output As #2 ' 打开输出文件。
' 将错误数据写入文件。 Open App.Path & Files For Input As #1 ' 打开SQL文件。
Do While Not EOF(1)
Line Input #1, Textline
If Not (Trim(Textline) = "GO") Then
SQL = SQL & Textline & Chr(13)
Else
Cn.Execute SQL 'Mid(SQL, InStr(SQL, "C"))
SQL = " "
End If
Loop
Close #1
Close #2
'If Creat_Table = False Then
' Shell App.Path & "\log.txt"
'End If
Exit Function
Err1:
Print #2, "This is a Error !"
Print #2, Err.Description
Print #2, Err.Number
Print #2, "**********"
Creat_Table = False
Resume Next
End Function
:我用的不是SQL SERVER 我用的是ACCESS