Path: csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Erland Sommarskog Newsgroups: comp.databases.ms-sqlserver Subject: Re: How do I best take a sql dump with contents where you can see pk and fk Date: Tue, 17 Jul 2012 00:07:06 +0200 Organization: Erland Sommarskog Lines: 21 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Injection-Info: mx04.eternal-september.org; posting-host="9c1143bfab35549403b85d70ea1a57d8"; logging-data="13203"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX195bsCNn4CtucVo4ujiVWHt" User-Agent: Xnews/2006.08.24 Mime-proxy/2.1.c.0 (Win32) Cancel-Lock: sha1:Q7C9Feu4yNsAW8WDBaMVDn2XaYg= Xref: csiph.com comp.databases.ms-sqlserver:1177 Tony Johansson (johansson.andersson@telia.com) writes: > I want to get the name of the columns, the primary key and foreign key and > the contents. > I want all this output to be stored in a file. > I can do select * but can I redirect the output to a file. You can save the output window. You can right-click in the query window and select Results To->File. There is also BCP and SQLCMD if you want to automate the operation. For tables and columns you can script the tables, and choose to script to file. -- Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se Links for SQL Server Books Online: SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx