Showing posts with label SQL. Show all posts
Showing posts with label SQL. Show all posts

Thursday, August 30, 2012

How do you transfer or export SQL Server 2005 data to Excel

Option 1:
  1. Right-click the database in SQL Management Studio
  2. Go to Tasks and then Export data, you'll then see an easy to use wizard.
  3. Your database will be the source, you can enter your SQL query
  4. Choose Excel as the target
  5. Run it at end of wizard

If you wanted, you could save the SSIS package as well (there's an option at the end of the wizard) so that you can do it on a schedule or something (and even open and modify to add more functionality if needed).


Option 2:

  1. Select menu item Query > Query Options.
  2. Set check box in Results > Grid > Include column headers when copying or saving the results.

After that, when you Select All and Copy the query results, you can paste them to Excel, and the column headers will be present.


Option3:

  1. Open Excel Data>Import/Export Data>Import Data Next to file name
  2. Click "New Source" Button On Welcome to the Data Connection Wizard,
  3. Choose Microsoft SQL Server. Click Next.
  4. Enter Server Name and Credentials.
  5. From the drop down box, choose whichever database holds the table you need.
  6. Select your table then Next.....
  7. Enter a Description if you'd like and click Finish.

When your done and back in Excel, just click "OK" Easy.

Tuesday, August 14, 2012

How can I move my database files in SQL Server?


  • Start SQL Server Management Studio
  • Expand the server instance, expand Databases
  • Right-click the database you want to move, and choose "Properties"
  • In the Properties window, choose "Files" and write down the current file paths. Click "Cancel"
  • Right-click the database again, and choose "Tasks - Detach..."
  • Click "OK" in the next window
  • Use Windows Explorer to move the data and log files (.mdf and .ldf) to the new location
  • Right-click Databases, and choose "Attach..."
  • In the "Attach databases" window, click "Add"
  • In the "Locate database files" window, browse to the new location and select the .mdf file. Click "OK"
  • In the details pane, verify that the new location is listed for both the .mdf and the .ldf file. Click "OK"
  • In SQL Server Management Studio, choose "View - Refresh" and verify that your database is listed again under Databases

Monday, May 23, 2011

SQL Best Practices - HDD Architecture

When possible,which is not always due to financial constraints) use:

C:\ OS
E:\ SQL Binaries
R:\ TempDB (1 file per processor, equi-sized)
S:\ Data
T:\ Log


and

C:\ RAID-1
E:\ RAID-5
R:\ RAID-1 or RAID-10
S:\ RAID-5
T:\ RAID-1 or RAID-10



Working with tempdb in SQL Server 2005
http://technet.microsoft.com/en-us/library/cc966545.aspx

Storage Top 10 Best Practices
http://technet.microsoft.com/en-us/library/cc966534.aspx

Disk Partition Alignment Best Practices for SQL Server
http://msdn.microsoft.com/en-us/library/dd758814(v=sql.100).aspx