0

Say I have code that executes a sql create table statement from outside my code, like so:

SqlConnection connection = new SqlConnection(aConnectionString);
connection.Open();
string createTable = System.IO.File.ReadAllText("CreateTable.sql");
SqlCommand command = new SqlCommand(createTable, connection);
command.ExecuteNonQuery();

Is it possible to determine the name of the newly created table WITHOUT parsing it directly from the sql statement string?

4

1 回答 1

0

这不是我认为的最佳解决方案……但是您可以使用此查询在数据库中创建/更改最后一个表。

select name,type,type_desc, create_date, modify_date from sys.objects
where  convert(varchar,modify_date,101)  =  convert(varchar,getdate(),101) AND type = 'U'
order by modify_date desc
于 2013-04-16T08:04:30.930 回答