Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SQL Query Analyzer

Posted on 2006-11-15
8
Medium Priority
?
347 Views
Last Modified: 2008-01-16
Hello EE,

I am looking for a script I can run that will export a certain table I need into a CSV (comma seperated file).

for exaple given the DB to pull from and the Technical name i need to  be able to export that table into a CSV

export TABLENAME DESTINATION NAME

Thanks

Chris
0
Comment
Question by:Clownzer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 28

Expert Comment

by:imran_fast
ID: 17947004
it will be something like
insert into openquery(execellinkedserver,'select * from sheet1$ where 1=1')
select * from sourcetable
0
 
LVL 28

Expert Comment

by:imran_fast
ID: 17947036
this is how you can add excel file as a linked server

EXEC sp_addlinkedserver EXCEL,
     'Jet 4.0',
     'Microsoft.Jet.OLEDB.4.0',
     'c:\data\MySheet.xls',
      NULL,
     'Excel 5.0;'

GO
0
 
LVL 3

Expert Comment

by:ia2189
ID: 17947147
Does it have to be in query analyzer?  You could do it fairly easily using the Data Transformation Services (DTS Local Package) that's found in Enterprise Manager.
0
 

Author Comment

by:Clownzer
ID: 17947605
Whatever is the easiest way to get the task accomplished. Our SQL DBA is out so it got dropped into my lap. Here is the email:

Hi XXXX,             
Here are the files I need for the W-2 work.             

Display Name      Technical Name                      Physical Name
Payroll Year End Header      UPR_Year_End_WORK_HDR      UPR10100
Payroll Year End Wage      UPR_Year_End_WORK_Wage      UPR10101
Payroll Year End Pension      UPR_Year_End_WORK_Pension      UPR10103
Payroll Year End Special      UPR_Year_End_WORK_Special      UPR10104
Payroll Year End State      UPR_Year_End_WORK_State      UPR10105
Payroll Year End Local      UPR_Year_End_WORK_Local      UPR10106
Payroll Year End Other      UPR_Year_End_WORK_Other      UPR10107

There will be a set of these files for all companies.             
            
The easiest way to send these files would be for one of your IT guys to go into the SQL Query tool and export the files as tab or comma delimited files.  If they would also identify all of the files by company that would help too.             
If you need me to visit with one of your IT guys just let me know.             
Thanks, XXX XXXXX      
0
 
LVL 30

Accepted Solution

by:
nmcdermaid earned 1000 total points
ID: 17954689
This email is suggesting that you:

1. Start Query Analyzer
2. Run a SELECT statement (from the Physical name, ie. SELECT * FROM UPR10100) that retrieves the data (Payroll stuff in Great Plains perhaps?)
3. Right click in the results grid, press Save As and save the results to a file.


If this is not automated then your DBA is clearly protecting his job. This kind of thing should not need manual intervention.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

618 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