Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27554

SQL Assistance, pulling data through select *

$
0
0
In VB.Net, I need to run the following SQL command:

select ';enable trigger ' + name + ' on ' + object_name(parent_id) from sys.triggers where name like '%_xml%'

That select statement returns a couple hundred lines. Those lines are then manually copied into the query window and ran.

I want to automate that, so I can run the command in VB.net (which I can), then copy that data and run that data as a new query. How would I do that? I don't understand how to get all of that information the select statement returns into a usable format in VB.Net to run those queries.

Below is some of the data returned by that statement, if it will help at all:

;enable trigger DO_RDG_MTR_SLS_XmlDelete on DO_RDG_MTR_SLS
;enable trigger PA_GP_CT_XmlInsertUpdate on PA_GP_CT
;enable trigger DO_CRDB_RQS_FR_XmlDelete on DO_CRDB_RQS_FR

The code I am using for the SQL connection and to run the select command is below:

Code:

            Dim connectionString As String
            Dim cnn As SqlConnection
            connectionString = "Data Source=(local); Integrated Security=SSPI"
            cnn = New SqlConnection(connectionString)
            cnn.Open()
            Dim cmd As SqlCommand
            Dim query As String
            query = ("select ';enable trigger ' + name + ' on ' + object_name(parent_id) from sys.triggers where name like '%_xml%'")
            cmd = New SqlCommand(query, cnn)
            cmd.CommandTimeout = 0
            cmd.ExecuteNonQuery()
            cnn.Close()

Any help would be greatly appreciated. Thank you!

Viewing all articles
Browse latest Browse all 27554

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>