Folks,
I am relatively new to sql server (coming from more of an oracle background) and was wondering if I could get some advice on the best way to proceed with solving the following problem. I need to create a file for a trading partner using information from our database. The file has multiple record layouts and the data for the file will come from multiple tables. For example we will have to do something like
if supplier = a then
for each order
create header record
write to file
for each line on order
create detail line
write to file
sum details
create summary record for order
write to file
now in an oracle world I would create a stored procedure with a number of cursors and use the UTL_FILE package to create the output file and run it using a batch script and sqlplus.
my proposed solution is to write a stored procedure and execute it using isql or osql (are these basically the same) in a dos bath script that would pass in the filename and directory. I beleive there is a system stored procedure that will write to a file. I have read a number of posts and begun looking at some sql server docs and see that a lot of people recommend staying away from cursors in sql server. Is there a reason for this? Also I see that you can put the results in a table and use bcp to create the file but this seems to be more of an adhoc solution rather than one that would be scheduled to run each day. Also I see a DTS package with sql server. Would this be a good way to create a file like I have described. And one last question (for now anyway). I think the following command will cause osql to execute a stored procedure.
OSQL -u <user> -P <password> -d <Database> -i <file.sql> -o <log file>
where file.sql would contain the statement EXEC @result = MyStoredProcedure(input parameters)
is this correct.
Thanks for any help.
I am relatively new to sql server (coming from more of an oracle background) and was wondering if I could get some advice on the best way to proceed with solving the following problem. I need to create a file for a trading partner using information from our database. The file has multiple record layouts and the data for the file will come from multiple tables. For example we will have to do something like
if supplier = a then
for each order
create header record
write to file
for each line on order
create detail line
write to file
sum details
create summary record for order
write to file
now in an oracle world I would create a stored procedure with a number of cursors and use the UTL_FILE package to create the output file and run it using a batch script and sqlplus.
my proposed solution is to write a stored procedure and execute it using isql or osql (are these basically the same) in a dos bath script that would pass in the filename and directory. I beleive there is a system stored procedure that will write to a file. I have read a number of posts and begun looking at some sql server docs and see that a lot of people recommend staying away from cursors in sql server. Is there a reason for this? Also I see that you can put the results in a table and use bcp to create the file but this seems to be more of an adhoc solution rather than one that would be scheduled to run each day. Also I see a DTS package with sql server. Would this be a good way to create a file like I have described. And one last question (for now anyway). I think the following command will cause osql to execute a stored procedure.
OSQL -u <user> -P <password> -d <Database> -i <file.sql> -o <log file>
where file.sql would contain the statement EXEC @result = MyStoredProcedure(input parameters)
is this correct.
Thanks for any help.