I’m trying to do this
declare @aspAccountName varchar(30);
SET @aspAccountName=HOST_NAME() + '\ASPNET';
IF NOT EXISTS (SELECT * FROM sys.server_principals WHERE name = @aspAccountName)
CREATE LOGIN (SELECT @aspAccountName) FROM WINDOWS WITH DEFAULT_DATABASE=[master]
But it says ‘Incorrect syntax near ‘@aspAccountName’ – any ideas ?
Thanks
You’d have to write the
CREATE LOGINportion as dynamic SQL.