Thanks Visakh16I've now got the following:DECLARE @str NVARCHAR(1000), @Date CHAR(8)SELECT @Date = CONVERT(VARCHAR,AlsDate,112) FROM SimpleDate SET @str='sqlcmd -S WS23\SQLSERVER2008 -E -d HelpAl -Q "SELECT * FROM SomeData;" -o D:\Results_'+@Date+'.bat -h -1'SELECT @strEXEC (@str)
When I try to execute in Management Studio (with sqlcmd mode enabled, I get the error:Msg 102, Level 15, State 1, Line 1Incorrect syntax near 'S'.I was getting this previously, hence used a bat file to execute the sqlcmd. Is there somethign I am missing, as I thought you could use the utility in MS if the mode was enabled?Hearty head pats