Code:
IF @@FETCH_STATUS = 0 THEN
EXECUTE IMMEDIATE 'ALTER TABLE ' + @aTableName + ' ALTER COLUMN ' + @aAutoIncField + ' CAST AS Integer IGNORE';
EXECUTE IMMEDIATE 'ALTER TABLE ' + @aTableName + ' ALTER COLUMN ' + @aAutoIncField + ' CAST AS AutoInc IGNORE';
END IF;
Zur Sicherheit solltest Du die Bezeichner noch quoten (falls sie Leerzeichen oder sonstige Sonderzeichen enthalten) und evtl trimmen:
Code:
IF @@FETCH_STATUS = 0 THEN
EXECUTE IMMEDIATE 'ALTER TABLE [' + trim(@aTableName) + '] ALTER COLUMN [' + trim(@aAutoIncField) + '] CAST AS Integer IGNORE';
EXECUTE IMMEDIATE 'ALTER TABLE [' + trim(@aTableName) + '] ALTER COLUMN [' + trim(@aAutoIncField) + '] CAST AS AutoInc IGNORE';
END IF;