[dba-SQLServer] Append temp table to tbl in SP

Gustav Brock Gustav at cactus.dk
Fri Mar 28 17:44:38 CDT 2008


Hi John

I would write SQL strings in .Net and then fire these as pass-through queries to the SQL Server engine.

/gustav

>>> jwcolby at colbyconsulting.com 28-03-2008 20:38 >>>
I have a bunch of databases with name / address info.  With all of them I
need to validate the name / address portion periodically, which means
exporting to CSV, feeding those files to a validation program, and then
reimporting the results into SQL Server.  AFAICT however I go about this I
will end up working with temporary tables.

I know how to "script to query window as..." and then cut and paste that to
get an append for example.  When I do that though it ends up with a list of
field names specific to the tables that I do this on.  That is fine for a
specific situation but not so fine if I want to do this over a dozen
databases.

Do I simply need to build this kind of SPs directly in each database and
then call that SP.  Doing that has the disadvantage of having to build each
such SP individually, and having the SPs fail if the tables ever change
field names or table names.  However it has the advantage that once done, it
just works until something breaks it (table name change, field name change
etc). 

I don't know enough about SQL Server and TSQL to see any alternative though.
Are there doable alternatives for situations like this?  If so can you
provide example code that is close enough to running that I can get it
working?

John W. Colby
Colby Consulting
www.ColbyConsulting.com 






More information about the dba-SQLServer mailing list