I have created a script to direct some query results to a text file ,the script is something like :
DECLARE @FileName varchar(50), @bcpCommand varchar(2000) SET @FileName = REPLACE('c:\authors_'+CONVERT(char(8),GETDATE(),1)+'.txt','/','-') SET @bcpCommand = 'bcp "select * from [open].dbo.devlab" queryout "' SET @bcpCommand = @bcpCommand + @FileName + '" -U sa -P lzbull@! -c' EXEC master..xp_cmdshell @bcpCommand
I have faced two problems if having an idea about one of them at least please advise :
1- the query directed includes information with a diffrent language then english (hindi, arabic...etc) i have notice that all the information written not in english appears in the text file as rubbish characters with no meaning , althought there is no problem in creating a manual text document with those languages, so how can i modify my script so that it writes proper characters in the text file for diffrent langauges ?
2- My script runs and works only when sql server is deffind as sql authentication , but if it is windows authentication i always get the message of unvalid login , so how can i but the correct user name and password in my script incase of windows authentication?