Script is not executed, and no error

Packages and compresses schema and contents of SQL Server databases

Moderators: JonathanWatts, Chris Auckland, David Atkinson, david connell, Anu Deshpande, Michelle Taylor, james.billings, Marianne

Script is not executed, and no error

Postby gfouet » Thu Oct 20, 2011 11:42 am

Hello,

I need urgent help with SQL Packager.

I packaged a script (which works perfectly when I run it manually). But when I start the .EXE, packager do its work, says everything is fine, but nothing changed in my database.

Here is the script :

Code: Select all
DECLARE @DB NVARCHAR(4000);
DECLARE @SQL NVARCHAR(4000);

SET @DB = DB_NAME();

IF ( EXISTS (SELECT * FROM sys.server_principals WHERE name = N'tlmcom') )
   SET @SQL = 'ALTER LOGIN ';
ELSE
   SET @SQL = 'CREATE LOGIN ';

SET @SQL = @SQL + '[tlmcom] WITH PASSWORD=N''1234'', DEFAULT_DATABASE=[' + @DB + ']' +
               ', DEFAULT_LANGUAGE=[French], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF';
EXECUTE(@SQL);
GO

EXEC dbo.sp_changedbowner @loginame = N'tlmcom', @map = false
GO


The command line :

Code: Select all
SQLcreateuser.exe /server:localhost,3169 /database:tlmcom_VxRx /username:SA /password:4321 /makeupgrade


Is it a bug in Packager ? Or what am I doing wrong ?
Thanks.
gfouet
 
Posts: 2
Joined: Thu Oct 20, 2011 11:27 am

Postby gfouet » Thu Oct 20, 2011 1:57 pm

I temporally removed the IF statement, and now it works.
Looks like Packager doesn't like my IF.
gfouet
 
Posts: 2
Joined: Thu Oct 20, 2011 11:27 am

Postby james.billings » Fri Oct 21, 2011 12:04 pm

What if you remove the bracketing? i.e.

Code: Select all
IF EXISTS (SELECT * FROM sys.server_principals WHERE name = N'tlmcom')
   SET @SQL = 'ALTER LOGIN ';
ELSE
   SET @SQL = 'CREATE LOGIN ';
james.billings
 
Posts: 1144
Joined: Wed Jun 16, 2010 11:10 am
Location: My desk.


Return to SQL Packager 6

Who is online

Users browsing this forum: No registered users and 0 guests