Wednesday, February 15, 2012

Exporting SQL column to excel

Hello. For my first post, I will admit I'm a SQL Newb. I don't know alot, but I am learning as fast as possible. My access to SQL databases in previous positions has been limited, but not here.

I have a list of database users which I'd like to change the passwords for across the board. The SQL writers have requested an Excel file with two columns (username and password to be), but I don't know how to export the single column in either a notepad document or into excel. Any help would be appreciated.

Thanks!There are literally dozens of ways to do this. For a one time deal I'll usually just copy past the columns out of Enterprise Manager or Query Analyzer. It will paste right into Excel no problem.

If you want to get a little more fancy with it you can use an Excel query. Excel is capable of connecting directly to SQL Server and pulling down data. Check out this little article that explains the basics.
http://iis.asu.edu/ceslab/kb/excelquery.htm|||Use query analyzer

Type the following code:

Select dbo.tablename.field1, dbo.tablename.field2 from tablename

tablename as ur tablename which contain the information u required. Field1 is ur fild name.

Example: If the database has user table and it has field like employeeid, employeename, employeepassword, employeemail.

you can select ur records by the following code

Select employeename, employeepassword from user

Run this code and copy ur result to excel sheet.

or you can use Queryanalyzer-->Query Menu-->Result to fle (Then run the code and save the file.

No comments:

Post a Comment