Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to export the field Routine_Definition from SQL Server to Excel??

Posted on 2014-03-03
3
Medium Priority
?
522 Views
Last Modified: 2014-03-03
I'm using this SQL Script to obtain a list of all of my Stored Procedures. This script contains a field that shows the entire TEXT found within each Stored Proc.

The issue is I need to get this data set result exported into EXCEL. When I attempt to COPY and/or IMPORT the data result set into Excel that data in field ROUTINE_DEFINITION will not import correctly. The field itself contains alot of text, commas, carriage returns, tabs etc and so is cauising the issue.

Is it possible to export a data set result such as this from sQL SERVER  into EXCEL..?

IF SO, ....HOW????

Here is the script if you'd like to try the export of the data yourself.


select SPECIFIC_CATALOG as [Database], specific_schema as [Schema], SPECIFIC_NAME as [StoredProcedureName], ROUTINE_DEFINITION as [StoredProcLogic],created  as [DateCreated], LAST_ALTERED  as [LastAltered]
  from YourDatabase.information_schema.routines
 where routine_type = 'PROCEDURE'
   and Left(Routine_Name, 3) NOT IN ('sp_', 'xp_', 'ms_')

Any assistance is greatly appreciated!
0
Comment
Question by:MIKE
  • 2
3 Comments
 
LVL 11

Accepted Solution

by:
John_Vidmar earned 2000 total points
ID: 39900449
If you copy/paste the results from a SQL tool into MS-Excel then you get the problem described (tabs put data into multiple columns).  MS-Excel can pull data directly from a database.  In MS-Excel 2003, under the Data-ribbon, Get External Data, use From SQL Server or From Microsoft Query (you'll need ODBC/DSN for this 2nd option).  A wizard will prompt you along the way.  When the results are imported into your sheet, I would change the column to allow wrapping.

In the future, you can open the MS-Excel Workbook and Refresh the data to get most recent changes to your stored-procedures.
0
 
LVL 17

Author Comment

by:MIKE
ID: 39900497
I'll try this and see what happens, be in touch with my resultrs...thanks for the direction.
0
 
LVL 17

Author Closing Comment

by:MIKE
ID: 39900507
PERFECTO..!!!! THANKS!!!
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how the fundamental information of how to create a table.

782 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question