You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ITSM/.svn/pristine/fc/fca5577d8e2f1bda3775d614939...

46 lines
1.6 KiB

Imports System.IO.File
Imports System.Data.SqlClient
Imports System.Data.SqlTypes
Imports System.ComponentModel
Imports System.IO
Imports System.SystemException
Imports System.Reflection
Public Class Form1
Dim param As New Parameters
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim con As New SqlConnection(param.ConnectionStringVVW)
DoIt(con)
End Sub
Private Sub DoIt(ByVal aconnection As SqlConnection)
'select 'execute sp_generate_inserts '+char(39) + [name] + char(39) + ',@ommit_identity=1' as ScriptStep from sys.objects where type in (N'U')
'select 'delete from dbo.'+char(39) + [name] + char(39) + ' where aktiv<>1 ' + char(13) + 'GO' as ScriptStep from sys.objects where type in (N'U')
Dim cmd As New SqlClient.SqlCommand("Select [name] from sys.objects where type in(N'U')", aconnection)
Dim da As New SqlClient.SqlDataAdapter(cmd)
Dim tmpds As New DataSet
da.Fill(tmpds, "Data")
Dim fw As StreamWriter
fw = New StreamWriter(param.TMPPath + "\Migrscript.sql")
Dim s As String
For Each dr As DataRow In tmpds.Tables(0).Rows
s = "Print 'Verarbeitung: " + dr.Item(0) + "'"
fw.WriteLine(s)
s = "execute sp_generate_inserts '" + dr.Item(0) + "',@commit_identity=1"
fw.WriteLine(s)
fw.WriteLine("Go")
''s = "delete from dbo." + dr.Item(0) + " where aktiv<>1"
''fw.WriteLine(s)
''fw.WriteLine("Go")
Next
fw.Flush()
fw.Close()
End Sub
End Class