SELECT name
FROM sys.procedures
WHERE Object_definition(object_id) LIKE '%ABC%'
2. 找尋最近修改的STORED PROCEDURE及TABLE
Select * from sys.objects
order by modify_date desc
以上兩條SQL都是我常用的,對Merge Code及Debug時非常有幫助,希望幫到大家
SELECT name
FROM sys.procedures
WHERE Object_definition(object_id) LIKE '%ABC%'
Select * from sys.objects
order by modify_date desc
using OPCAutomation;
public class OPC
{
OPCServer KepServer;
OPCGroups KepGroups;
OPCGroup KepGroup;
OPCItems KepItems;
OPCItem KepItem;
string strHostIP = "";
string strHostName = "";
int itmHandleClient = 0;
public bool GetLocalServer()
{
IPHostEntry IPHost = Dns.GetHostEntry(Environment.MachineName);
if (IPHost.AddressList.Length > 0)
{
strHostIP = IPHost.AddressList[0].ToString();
}
else
{
MessageBox.Show("GetLocalServer Error 1");
return false;
}
IPHostEntry ipHostEntry = Dns.GetHostEntry(strHostIP);
strHostName = ipHostEntry.HostName.ToString();
try
{
KepServer = new OPCServer();
object serverList = KepServer.GetOPCServers();
KepServer.Connect(((Array)serverList).GetValue(1).ToString(),"localhost");
}
catch(Exception ex)
{
MessageBox.Show("GetLocalServer Error 2 " + ex.Message);
return false;
}
return true;
}
public bool CreateGroup()
{
try
{
KepGroups = KepServer.OPCGroups;
KepGroup = KepGroups.Add("MaxsonProgram");
SetGroupProperty();
KepGroup.DataChange += new DIOPCGroupEvent_DataChangeEventHandler(KepGroup_DataChange);
KepGroup.AsyncWriteComplete += new DIOPCGroupEvent_AsyncWriteCompleteEventHandler(KepGroup_AsyncWriteComplete);
KepItems = KepGroup.OPCItems;
}
catch (Exception err)
{
MessageBox.Show(err.Message, "CreateGroup提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return false;
}
return true;
}
public void SetGroupProperty()
{
KepServer.OPCGroups.DefaultGroupIsActive = true;
KepServer.OPCGroups.DefaultGroupDeadband = 0;
KepGroup.UpdateRate = 1000;
KepGroup.IsActive = true;
KepGroup.IsSubscribed = true;
}
void KepGroup_AsyncWriteComplete(int TransactionID, int NumItems, ref Array ClientHandles, ref Array Errors)
{
MessageBox.Show("Success Write");
}
void KepGroup_DataChange(int TransactionID, int NumItems, ref Array ClientHandles, ref Array ItemValues, ref Array Qualities, ref Array TimeStamps)
{
}
public void opcWrite(string tagname, string value)
{
try
{
Array Errors;
int cancelID;
KepItem = KepItems.AddItem(tagname, itmHandleClient);
int[] temp2 = new int[2] { 0, KepItem.ServerHandle };
Array serverHandles = (Array)temp2;
object[] valueTemp = new object[2] { "", value };
Array values = (Array)valueTemp;
KepGroup.AsyncWrite(1, ref serverHandles, ref values, out Errors, 2009, out cancelID);
KepItems.Remove(KepItems.Count, ref serverHandles, out Errors);
GC.Collect();
}
catch (Exception ex) { MessageBox.Show(ex.Message); }
}
}
OPC opc = new OPC();
if (opc.GetLocalServer())
{
if (opc.CreateGroup())
{
opc.opcWrite("SuiteLink.Topic.Test02", "30");
opc.opcWrite("SuiteLink.Topic.Rainfall_Value", "10.33");
opc.opcWrite("SuiteLink.Topic.Rainfall_X", "123.456");
opc.opcWrite("SuiteLink.Topic.Rainfall_Y", "654.321");
opc.opcWrite("SuiteLink.Topic.WinterMode", "1");
opc.opcWrite("SuiteLink.Topic.NormalMode", "0");
opc.opcWrite("SuiteLink.Topic.TriggerLevel", "1.6");
opc.opcWrite("SuiteLink.Topic.RainingState", "0");
}
} 
this.backgroundWorker1.WorkerReportsProgress = true;
this.backgroundWorker1.DoWork += new System.ComponentModel.DoWorkEventHandler(this.backgroundWorker1_DoWork);
this.backgroundWorker1.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.backgroundWorker1_ProgressChanged);
void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
// The progress percentage is a property of e
toolStripProgressBar1.Value = e.ProgressPercentage;
}
void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
Args arg = (Args)e.Argument;
string a = arg.a;
string b = arg.b;
backgroundWorker1.ReportProgress(0);
label1.Invoke(new Action(() => { label1.Text = b; }));
backgroundWorker1.ReportProgress(30);
Thread.Sleep(1000);
backgroundWorker1.ReportProgress(60);
label1.Invoke(new Action(() => { label1.Text = a; }));
backgroundWorker1.ReportProgress(100);
Thread.Sleep(1000);
backgroundWorker1.ReportProgress(0);
button1.Invoke((Action)(() => button1.Enabled = true));
}
internal class Args
{
internal string a { get; set; }
internal string b { get; set; }
}
private void button1_Click(object sender, EventArgs e)
{
button1.Enabled = false;
var args = new Args() { a = "YES", b = "NO" };
backgroundWorker1.RunWorkerAsync(args);
}




var watch = Stopwatch.StartNew();
//Do Work
watch.Stop();
var elapsedMs = watch.ElapsedMilliseconds;
label1.Text = (dlapsedMs / 1000.00).ToString() + " s";