cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
jstuardo
Level 4

SQL script fail

Hello...

I am having problems with an execution of SQL Script. This is it:

USE [{%DATABASE%}]
GO

IF NOT EXISTS
(SELECT name
FROM sys.database_principals
WHERE name = '{%USERNAME%}')
BEGIN
CREATE LOGIN [{%USERNAME%}]
WITH PASSWORD = N'{%PASSWORD%}',
DEFAULT_DATABASE = [{%DATABASE%}],
CHECK_EXPIRATION = OFF,
CHECK_POLICY = OFF;

CREATE USER {%USERNAME%} FOR LOGIN {%USERNAME%};
END

I have of course, variable replacements.

When I run this in SQL Query Manager, it works, but when IS is what executed it, the attached error occurs.



Is there a way to debug this issue? for example, to know exactly what SQL command is being sent to the database engine?

Any help will be greatly appreciated

Thanks
Jaime
Labels (1)
0 Kudos
(1) Reply
hidenori
Level 17

Try using the SQL Server Profiler to trace the instance of SQL Server.
0 Kudos