Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to save data in a file
Message
De
17/05/2005 13:29:28
Keith Payne
Technical Marketing Solutions
Floride, États-Unis
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
01014572
Message ID:
01015001
Vues:
24
>Hi,
>
>I have a stored procedure that accepts one parameter. It returns 200 rows and three columns as it has select statement. I want to run it number of times there is value in states table and wants to store the out put in excel file. Since it will run 53 times with state name as parameter I used the cursor to run it. Here is an example. Can anyone tell me how to copy the out put into the excel file with new name with each run of stored procedure.
>
>
>DECLARE State_cursor CURSOR
>FOR
> SELECT cstate
> FROM states
>OPEN State_cursor
>DECLARE @cstate varchar(2)
>FETCH NEXT FROM State_cursor INTO @cstate
>WHILE (@@FETCH_STATUS <> -1)
>BEGIN
> IF (@@FETCH_STATUS <> -2)
> BEGIN
>exec Bsp_Prov_report @cstate
>END
> FETCH NEXT FROM State_cursor INTO @cstate
>END
>CLOSE State_cursor
>DEALLOCATE State_cursor
>
>
>Thanks
>Bharat

Bharat,

If you open Excel with a blank spreadsheet and run "New Database Query" from the tools menu, you can get the data into the spreadsheet. You cannot create a spreadsheet from within SQL server.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform