October 7, 2010 at 4:22 am
I'm running this statement in a try/catch block:-
alter table ref.[User] alter column EmployeeID smallint not null
The catch is defined as:-
begin catch
SELECT
ERROR_NUMBER() AS ErrorNumber
,ERROR_SEVERITY() AS ErrorSeverity
,ERROR_STATE() AS ErrorState
,ERROR_PROCEDURE() AS ErrorProcedure
,ERROR_LINE() AS ErrorLine
,ERROR_MESSAGE() AS ErrorMessage;
end catch
And this results in the output:-
4922 16 9 NULL 64 ALTER TABLE ALTER COLUMN EmployeeID failed because one or more objects access this column.
However, when I run that ALTER statement on its own in SSMS, I get the stack of errors:-
Msg 5074, Level 16, State 1, Line 1
The object 'PK_Users' is dependent on column 'EmployeeID'.
Msg 4922, Level 16, State 9, Line 1
ALTER TABLE ALTER COLUMN EmployeeID failed because one or more objects access this column.
Note that the stack of errors tells me what the problem is - that PK_Users is dependent - but the output in the CATCH statement is only giving me the last erron in the stack, which isn't enough to actually identify the problem.
Is there a way to get the whole error stack listed?
October 7, 2010 at 4:25 am
Sorry, no idea how I managed to post in this part of the forum !!??
I've re-posted it in the 2008 General one.
I'm looking for the Delete option to get rid of this post now!
October 7, 2010 at 6:08 am
no. you can remove any post, either you can edit it and remove the post's text
-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply