Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #1174 > unrolled thread

How do I best take a sql dump with contents where you can see pk and fk

Started by"Tony Johansson" <johansson.andersson@telia.com>
First post2012-07-16 13:59 +0200
Last post2012-07-17 06:14 -0700
Articles 6 — 4 participants

Back to article view | Back to comp.databases.ms-sqlserver


Contents

  How do I best take a sql dump with contents where you can see pk and fk "Tony Johansson" <johansson.andersson@telia.com> - 2012-07-16 13:59 +0200
    Re: How do I best take a sql dump with contents where you can see pk and fk Erland Sommarskog <esquel@sommarskog.se> - 2012-07-16 23:54 +0200
      Re: How do I best take a sql dump with contents where you can see pk and fk "Tony Johansson" <johansson.andersson@telia.com> - 2012-07-17 00:01 +0200
        Re: How do I best take a sql dump with contents where you can see pk and fk Erland Sommarskog <esquel@sommarskog.se> - 2012-07-17 00:07 +0200
        Re: How do I best take a sql dump with contents where you can see pk and fk "Bob Barrows" <reb01501@NOSPAMyahoo.com> - 2012-07-16 19:35 -0400
    Re: How do I best take a sql dump with contents where you can see pk and fk rja.carnegie@gmail.com - 2012-07-17 06:14 -0700

#1174 — How do I best take a sql dump with contents where you can see pk and fk

From"Tony Johansson" <johansson.andersson@telia.com>
Date2012-07-16 13:59 +0200
SubjectHow do I best take a sql dump with contents where you can see pk and fk
Message-ID<ju0vmv$d1h$1@dont-email.me>
Hello!

I need to extract a sql dump from several tables where I can see the contens 
and primary key and foreign key

//Tony 

[toc] | [next] | [standalone]


#1175

FromErland Sommarskog <esquel@sommarskog.se>
Date2012-07-16 23:54 +0200
Message-ID<XnsA092F33A6DD1CYazorman@127.0.0.1>
In reply to#1174
Tony Johansson (johansson.andersson@telia.com) writes:
> I need to extract a sql dump from several tables where I can see the
> contens and primary key and foreign key 
 
SELECT *? Or do you want the "dump" in any special format? Can you
be more specific?

-- 
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

[toc] | [prev] | [next] | [standalone]


#1176

From"Tony Johansson" <johansson.andersson@telia.com>
Date2012-07-17 00:01 +0200
Message-ID<ju2317$i4m$1@dont-email.me>
In reply to#1175
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.

//Tony

"Erland Sommarskog" <esquel@sommarskog.se> skrev i meddelandet 
news:XnsA092F33A6DD1CYazorman@127.0.0.1...
> Tony Johansson (johansson.andersson@telia.com) writes:
>> I need to extract a sql dump from several tables where I can see the
>> contens and primary key and foreign key
>
> SELECT *? Or do you want the "dump" in any special format? Can you
> be more specific?
>
> -- 
> 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
> 

[toc] | [prev] | [next] | [standalone]


#1177

FromErland Sommarskog <esquel@sommarskog.se>
Date2012-07-17 00:07 +0200
Message-ID<XnsA093134310A7Yazorman@127.0.0.1>
In reply to#1176
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

[toc] | [prev] | [next] | [standalone]


#1178

From"Bob Barrows" <reb01501@NOSPAMyahoo.com>
Date2012-07-16 19:35 -0400
Message-ID<ju28ff$hrs$1@dont-email.me>
In reply to#1176
Still not enough specific information. How do you intend that the primary 
and foreign keys be stored in the file? As a separate resultset? Show us 
what you want to see in the file given a 3-colomn table with three rows, a 
primary key on the first column and a foreign key on the third.  Exactly 
what will the file contain. Will it be a text file? If so, show us the text.

Tony Johansson wrote:
> 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.
>
> //Tony
>
> "Erland Sommarskog" <esquel@sommarskog.se> skrev i meddelandet
> news:XnsA092F33A6DD1CYazorman@127.0.0.1...
>> Tony Johansson (johansson.andersson@telia.com) writes:
>>> I need to extract a sql dump from several tables where I can see the
>>> contens and primary key and foreign key
>>
>> SELECT *? Or do you want the "dump" in any special format? Can you
>> be more specific?
>>

[toc] | [prev] | [next] | [standalone]


#1179

Fromrja.carnegie@gmail.com
Date2012-07-17 06:14 -0700
Message-ID<04679e06-534a-48a5-9b50-2726b5854d56@googlegroups.com>
In reply to#1174
On Monday, July 16, 2012 12:59:12 PM UTC+1, Tony Johansson wrote:
> Hello!
> 
> I need to extract a sql dump from several tables where I can see the contens 
> and primary key and foreign key

If you have SQL Server 2005 or later, then in Management Studio
you can probably "Export" data by right-clicking on the database
name.  CSV or Microsoft Excel may be useful external data formats
when you're getting started with this.  As far as I recall,
you can also move smoothly from this into SSIS for a job that
you can re-run on demand for multiple tables, but some maniac
persuaded the braindead management here to have SSIS removed 
from all of our servers, presumably in order to stop employees
acquiring skills that other employers that pay better will want.
Of course, this takes down data import and export in 
Management Studio, as well.  

BCP is a very, very old tool now, and, in my experience, 
is cranky.  And I have a lot of experience, or it feels that way.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.databases.ms-sqlserver


csiph-web