Achei um que funciona 100%
Parece que é do Leandro Daldegam
Código:
declare @memb___id varchar(10)
declare @vip int
declare @value varchar(255)
declare @address varchar(255)
SET @address = 'C:\MuServer\Data\ConnectMember.txt'
SET @value = 'DEL '+ @address
exec MASTER..XP_CMDSHELL @value
declare c cursor for select memb___id, vip FROM MEMB_INFO
open c
FETCH NEXT FROM c INTO @memb___id, @vip
WHILE @@FETCH_STATUS = 0
BEGIN
IF @vip = 1
BEGIN
SET @value = 'ECHO;"' + @memb___id + '" >> '+ @address
exec MASTER..XP_CMDSHELL @value
print @value;
END
FETCH NEXT FROM c INTO @memb___id, @vip
END
CLOSE c
DEALLOCATE c