1.
I am running the following osql command from within a stored procedure (I took out all sensitive info
). I get the following error message: '[ODBC Driver Manager] Data source name not found and no default driver
specified' I checked my ODBC connection in the ODBC connection manager and it connects just fine. What else could be causing this?
2.
When I run just the command (the @cmd variable from below) from the command prompt, the output file spools fine. However, the data isn't aligned properly like it would if I was trying to save to file (txt or rpt) from Query Analyzer. I have tried saving to txt and rpt and both return the same results. Is there any way to improve this?
I would like to do the osql command within a stored procedure b/c the query within the input.sql needs to run daily. Any advice is welcome! Thanks
DECLARE @BaseLocation VARCHAR(80)
DECLARE @BaseFileName VARCHAR(80)
DECLARE @cmd VARCHAR(200)
DECLARE @status INT
DECLARE @date VARCHAR(8)
BEGIN
SET @date = convert(char(8),getdate(),112)
WAITFOR DELAY '00:00:1'
SET @cmd = 'isql -S<servername> -D<database_name> -U<username> -P<pwd> -iC:\input.sql -oC:\output.txt'
exec master..xp_cmdshell @cmd
END
I am running the following osql command from within a stored procedure (I took out all sensitive info
specified' I checked my ODBC connection in the ODBC connection manager and it connects just fine. What else could be causing this?
2.
When I run just the command (the @cmd variable from below) from the command prompt, the output file spools fine. However, the data isn't aligned properly like it would if I was trying to save to file (txt or rpt) from Query Analyzer. I have tried saving to txt and rpt and both return the same results. Is there any way to improve this?
I would like to do the osql command within a stored procedure b/c the query within the input.sql needs to run daily. Any advice is welcome! Thanks
DECLARE @BaseLocation VARCHAR(80)
DECLARE @BaseFileName VARCHAR(80)
DECLARE @cmd VARCHAR(200)
DECLARE @status INT
DECLARE @date VARCHAR(8)
BEGIN
SET @date = convert(char(8),getdate(),112)
WAITFOR DELAY '00:00:1'
SET @cmd = 'isql -S<servername> -D<database_name> -U<username> -P<pwd> -iC:\input.sql -oC:\output.txt'
exec master..xp_cmdshell @cmd
END