Focal Point
[Solved] delete or rename a SQL table via DataMigrator

This topic can be found at:
http://forums.informationbuilders.com/eve/forums/a/tpc/f/1381057331/m/7447070196

January 28, 2019, 04:06 PM
folkie
[Solved] delete or rename a SQL table via DataMigrator
Is there a way to delete or rename a table from a SQL database using DataMigrator (Data Management Console)? I was hoping there would be something in the target properties I could use, but I don't see it. NOTE: I'm not asking about deleting all the records in the table (I know how to do that). I'm asking how to delete the SQL table from the database.

The database is on Microsoft SQL server version 13.00.4001, Windows 2016. I get to the SQL db via an Access 2010 Project. When this db was on an older server (Windows 2008), I could delete and rename tables (and do other things) via an Access 2010 Project. But things have changed on this new server.

Now, I get a message saying it can't find the object (that I've already selected) or this recordset is not updateable, or the stored procedure executed successfully but did not return records, or nothing happens when I try to delete it. And similar when trying to rename a table.

Thanks,
Mark

This message has been edited. Last edited by: folkie,


WF 8.2.02
App Studio
DataMigrator
ReportCaster
Windows Server 2016
January 29, 2019, 08:54 AM
Tsepe
Hi

You can create a procedure and use this to execute your DDL script to alter or drop the table


ENGINE SQLMSS SET DEFAULT_CONNECTION SQLCONN1
SQL SQLMSS COMMIT
SQL SQLMSS

DROP TABLE dbo.TBL1
-RUN


iWay Datamigrator 76,
iWay Service Manager 5.5, Windows server 2000,
January 29, 2019, 11:04 AM
folkie
Tsepe,

Thanks for the info. I'm not very familiar with SQL other than what I used to be able to do via an Access Project, or with DataMigrator. I had to lookup what DDL means (Data Definition Language).

I created a new procedure and adapted the code you provided and it worked fine for deleting/dropping a table. I even learned how to drop multiple tables in one script (separate the table names with a comma).

But for renaming a table, ALTER didn't work for me (or I couldn't figure it out). I had to use a stored procedure called sp_rename because I’m using SQL Server - syntax: sp_rename 'Test_Table_Date1', 'Test_Table_Date2';

I like using comments wherever appropriate. But the DDL script didn’t seem to like too many comments (starting and ending with /* and */) and/or where I placed the comments.

But, based on your reply, I was able to do what I wanted.

Thanks a lot,
Mark


WF 8.2.02
App Studio
DataMigrator
ReportCaster
Windows Server 2016
January 29, 2019, 11:43 AM
folkie
Regarding comments, I found that using the normal Focus comment of -* at the start of lines (instead of /* and */) works fine if I put them all at the top of the procedure. I didn't try to put them in the middle of the procedure.

Thanks,
Mark


WF 8.2.02
App Studio
DataMigrator
ReportCaster
Windows Server 2016