Queries are for modelling data.
Use tools like BCP or SqlCmd to export data
https://learn.microsoft.com/en-us/sql/tools/bcp-utility?view=sql-server-ver15
https://learn.microsoft.com/en-us/sql/tools/sqlcmd-utility?view=sql-server-ver15
xml string as file
Hi,
I have Nvarchar(max) column where xml string has been stored.
i wants to download that xml string as file. how to write the query for that?
Thanks
2 answers
Sort by: Most helpful
-
Olaf Helper 44,501 Reputation points
2022-03-15T09:06:55.32+00:00 -
Bert Zhou-msft 3,421 Reputation points
2022-03-15T09:22:58.433+00:00 Welcome to Microsoft T-SQL Q&A Forum!
As experts say, you can use sqlcmd Mode. It allows to output result of a query to a local file system.
Please check this:
-- switch to SQLCMD Mode :out e:\Temp\outputFileName.xml SET NOCOUNT ON; SELECT [CurrencyCode] ,[Name] ,[ModifiedDate] FROM [AdventureWorks].[Sales].[Currency] FOR XML PATH('row'), TYPE, ROOT('root');
Here is a detailed article about sqlcmd, you can refer to it.
Best regards,
Bert Zhou
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.