Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
nguyenl
Posting Yak Master
128 Posts |
Posted - 2008-03-20 : 16:40:55
|
| Hi,I was wondering what SQL code would allow me to extract my results into a .txt.For example:Select * from employees(What should I write here to enable me to import it into a .txt file and save it on a network drive?)Thanks |
|
|
tosscrosby
Aged Yak Warrior
676 Posts |
Posted - 2008-03-20 : 17:28:11
|
| You can use DTS (SQL2K) to export to a file in several different formats. Right click on the table in EM and select export data. A wizard will popup. Follow it from there.Terry |
 |
|
|
nguyenl
Posting Yak Master
128 Posts |
Posted - 2008-03-20 : 19:09:37
|
| Is there anyway to write this manually? My script involves multiple tables and joins.For example:select distinct compass_compass_cd_cd, code_table.code_table_cd into #compass_cdfrom cmpnt_address,code_tablewhere cmpnt_address.compass_compass_cd_cd = code_table.idgoselect distinct street_type_cd, code_table.code_table_cd into #street_cdfrom cmpnt_address,code_tablewhere cmpnt_address.street_type_cd = code_table.idgoSELECT address_id, cmpnt_address.street_number, cmpnt_address.number_compass_cd, cmpnt_address.to_number, cmpnt_address.to_number_compass_cd, cmpnt_address.unit_number, compass_cd.code_table_cd compass_cd, cmpnt_address.street_name, street_cd.code_table_cd street, compass_cd.code_table_cd compass_cd, address.city, address.zip_postal_code, cmpnt_address.unit_cd FROM property, cmpnt_address, address, compass_cd, --outer compass_cd suffix, street_cdWHERE property.situs_address_id = cmpnt_address.address_id AND cmpnt_address.street_type_cd = street_cd.street_type_cd AND cmpnt_address.address_id = address.id AND cmpnt_address.compass_compass_cd_cd = compass_cd.compass_compass_cd_cd AND cmpnt_address.compass_compass_cd_cd = compass_cd.compass_compass_cd_cdORDER BY address_idI would lIke to them export this into a .txt file. |
 |
|
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2008-03-21 : 20:26:53
|
| You can run sql statement with sqlcmd, that let you specify output file. |
 |
|
|
|
|
|
|
|