I have an output that is writing to a database (create) and I'd like to run the following SQL post create. How should this be handled?
ALTER table Person ALTER column PersonID integer not null GO ALTER table Person add primary key (PersonID)
Edit:
When adding this statement to the Post Create SQL Statement - I receive the following error.
Incorrect syntax near 'GO'
Solved! Go to Solution.
Do you want to make this change before any data is entered or afterwards?
When using an OLEDB output, there is a place to configure a Post Create SQL statement, and you should be able to put the query there.
Thanks for your comment - but I actually was getting an error when I configured the Post Create SQL Statement in the output tool. I've edited my original question to include this.
It should work if you remove the "GO".
Hopefully that helps!
Unfortunately when I remove the "GO" I get a different error because I'm trying to alter a PK constraint on a nullable field, one that is also being altered in the same batch. Creating a child batch using EXEC seemed to work:
ALTER table Person ALTER column PersonID integer not null EXEC(' ALTER table Person add primary key (PersonID) ')
Ref: https://stackoverflow.com/questions/15740997/alter-table-then-update-in-single-statement
Remove Go, add a semicolon at the end of each query.
ALTER table Person ALTER column PersonID integer not null; ALTER table Person add primary key (PersonID);