Jason and David,
In asking the question WHY are people asking for this I thought I might be able to offer some insight. Please keep in mind I am not an expert and what I say should not be considered the "final answer" nor am I arguing that what I am about to say it the only way it could be done.
At the shop I work at (and for the commercial app I am writing) TSQL script gives us a "scripty" way to create the database and (more importantly) update the database per version release of the software without having to hard code those changes into our application or assembly.
We create a TSQL script for each version release of our software. We embed that script into the assembly as a text-based resource file. That combined with our custom .net updater code will look at the current version of the application and automatically apply and iterate through each of these resource files and automatically apply them to the database by executing the scripts against the database and then storing in a configuration table/field the last applied update. So that update code only runs when there is a mismatch between current version of the assembly and latest update value stored in the database.
One of the business requirements of those scripts is that you have to be able to run them more than once without duping rows or causing DDL errors.
So they have a lot of If NOT EXIST (SELECT 1 FROM SOMETABLE WHERE...) in it to prevent duping the rows. But to prevent the DML errors we have to do stuff like IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'mytable' AND COLUMN_NAME = 'mycolumn') ALTER TABLE...
The nice thing about using t-sql script to do this is you can nicely combine the ddl changes with the data modifications. So you don't update this column until the column is added but you also need to be able to verify that the column exists before running the dml changes.
I suppose there is a pure ado.net way to accomplish this but our tsql way has worked very well for us and we would like to be able to do something similar using VistaDB.
Any thoughts?
Seth B Spearman
js_vistadb wrote:Look up information on GetSchema() that is how you are supposed to get table and column information from an ADO.NET provider.
You can get information from [database schema] but it is not the recommended way, and you cannot self join on that virtual table.
The help has information about that as well.