Пожалуйста, попробуйте следующие изменения:
declare @Name varchar(100),@sql varchar(400),@sql2 varchar(400),@sql3 varchar(400) ,@sql4 varchar(400)
declare @psw varchar(10) = 'Traf@12345';
declare @T table (Name varchar(100)) ;
insert into @T values
('SampleUser1'),
('SampleUser2')
While exists(select * from @T)
begin
select top 1 @Name = name from @T
IF NOT EXISTS (SELECT [name] FROM [sys].[sql_logins] WHERE [name] = @Name)
BEGIN
SET @sql = 'CREATE LOGIN '+'['+@name+']'+' WITH PASSWORD ='''+ @psw + '''; '
EXEC (@sql)
END
DELETE FROM @T WHERE Name = @Name
END