Tuesday, January 28, 2014

SQL Reference two database instances in a query


Within a SQL query or stored procedure, multiple database tables can be referenced.  The full database name just needs to be specified in the query.

 

SELECT *

FROM Appointment a

INNER JOIN TableLog.dbo.Appointment al ON al.appointmentid=a.appointmentid

WHERE a.appointmentid = @appointmentid

C# use a Type in a generic method definition

To use a Type within a generic method initialization, it can be accomplished with:


MethodInfo method = typeof(NameOfClass).GetMethod("MethodName", BindingFlags.Public | BindingFlags.Static);

method = method.MakeGenericMethod(type);
 
string results = (string)method.Invoke(null, new object[] { props[key] });