Search code examples
sqlsql-server-2012altersql-server-profiler

SQL statement is executed but not effectuated


Website with an underlying SQL 2012 database:

An ALTER TABLE for adding a column is executed. The website is setup for using an SQL-account (we'll call it myAccount), and this account is db_owner.

The statement is

ALTER TABLE [ItemType_Website_Settings] ADD [myNumber] INT NULL DEFAULT(0)

The ALTER TABLE statement is registered by SQL Profiler with a BatchCompleted. But refreshing the table, the column has not been created.

Also

SELECT t.name AS table_name,
SCHEMA_NAME(schema_id) AS schema_name,
c.name AS column_name
FROM sys.tables AS t
INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID
WHERE c.name LIKE 'myNumber'
ORDER BY schema_name, table_name; 

does not give any records.

BUT: Going to SQL Management Studio, using the before mentioned SQL-account "myAccount", and executing the same ALTER TABLE from here, the column is created just fine..?

Any clues? I'm totally lost here.

Thanx in advance for your input.

-- RESOLVED -- Profiler got the batch, but it was never committed.

Best regards Morten Snedker


Solution

  • I think this is the Issue of uncommitted transaction you have to commit your transaction after Alter table statement executed .