Parsing T-SQL Statements with SQLDMO sqldmoparsesql Illustrates how you can parse T-SQL statements against an SQL Server with SQL-DMO. C# .Net Fun - http://www.dotnetfun.com - Michael G.
strSQLToParse System.String The T-SQL you want to parse. "SELECT Ouch Invalid SQL!" strSQLServer System.String The name of the SQL Server you want to parse against. "MYSERVERNAME" strLoginID System.String The login ID used to connect to the SQL Server you want to parse against. "sa" strLoginPassword System.String The login password used to connect to the SQL Server you want to parse against. "password" strDatabase System.String The database you want to parse the T-SQL against. "MyDatabase" strDatabaseOwner System.String The owner of the database you want to parse the T-SQL against (can be null). "dbo" :\Program Files\Microsoft SQL Server\\Tools\Binn SQLDMO.SQLServerClass sqlServer = new SQLDMO.SQLServerClass(); try { String strSQLToParse = $strSQLToParse$; sqlServer.Connect($strSQLServer$, $strLoginID$, $strLoginPassword$); SQLDMO._Database db = sqlServer.Databases.Item($strDatabase$, $strDatabaseOwner$); try { db.ExecuteImmediate(strSQLToParse, SQLDMO.SQLDMO_EXEC_TYPE.SQLDMOExec_ParseOnly, null); } catch (Exception e) { // Parse error... } } catch (Exception err) { // SQL-DMO Error... } finally { sqlServer.Close(); sqlServer = null; } ]]>