0

次のように、コードの外側から sql create table ステートメントを実行するコードがあるとします。

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

SQLステートメント文字列から直接解析せずに、新しく作成されたテーブルの名前を特定することは可能ですか?

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 に答える