I’m currently writing a special report in T/SQL.
Basicly, I’ve got a table containing windows usernames, and I have to run a stored procedure once for each person (Using a cursor). This can easily be done using the EXECUTE AS USER = 'domain\username'. However, if a user loses his windows login after the table is generated, i get the following error:
Could not obtain information about Windows NT group/user 'domain\user', error code 0x5.
This error stops the procedure completely, which will give me an error. Is there a way to ignore this message and just skip to the next cursor value?
In advance, thanks
Gunnar S. Knudsen
If you are using SQL 2005 or higher, you can use TRY…CATCH (Transact-SQL). Here’s the example from the provided link: