# Miscellaneous > General Database Discussions >  New to SQL Server:  How to Import a .Dat file?

## Dave McGrath

I just loaded SQL Server on my local NT Server.  Client gave me several .dat files.  I created a new device and database with the same name (catalog.dat) shut down the server, overwrote the new .dat file with the client`s file, opened up SQL Server and now the catalog database says "Suspect" and it cannot be accessed via SQL/w....

What am I doing wrong?

I have a solid Access background, but I fear that SQL Server is a totally different animal...  HeeeelP!??!?!

Thanks!

Dave McGrath

----------


## Ninel Roytman

You can use BCP for loading the data. First make sure you set
 `Select Into/Bulk Copy`  option to true (double-click on Database name in 
the Server Manager window; you get `Edit Database`  screen; 
go to `Options` tab; check this option). Take a look at your .dat file:
how many columns, what dataformat has data in the columns and 
what delimiter to separate columns is used. 
Create table with proper for this .dat file structure 
(actually it doesn`t have to match exactly).
Then use BCP  `in`   from a DOS prompt.

Basic syntax is:
bcp database_name..table_name in dat_file_pathdat_file_name /U sa /P sa_password /S server_name 

Take a look at Books Online for BCP programm help. Very helpful.

----------


## Alex

On 9/18/98 11:37:54 AM, Dave McGrath wrote: 
> I just loaded SQL Server on my local NT Server.  Client gave me several 
> .dat files.  I created a new device and database with the same name 
> (catalog.dat) shut down the server, overwrote the new .dat file with the 
> client`s file, opened up SQL Server and now the catalog database says 
> "Suspect" and it cannot be accessed via SQL/w....

What am I doing 
> wrong?

I have a solid Access background, but I fear that SQL Server is a 
> totally different animal...  HeeeelP!??!?!

Thanks!

Dave McGrath

----------


## Jasper

On 9/18/98 11:37:54 AM, Dave McGrath wrote: 
> I just loaded SQL Server on my local NT Server.  Client gave me several 
> .dat files.  I created a new device and database with the same name 
> (catalog.dat) shut down the server, overwrote the new .dat file with the 
> client`s file, opened up SQL Server and now the catalog database says 
> "Suspect" and it cannot be accessed via SQL/w....

I think that your problem lies with the creation order of the Client DB. I have used this method to transfer DBs from server to server successfully. But these DB were created with one `unfragmented` Data device and one `unfragmented` Log device.

If you create a DB, but need to extend the log of data devices, they will have been created, and stored in a `fragmented` order. Therefore, overwriting a new `unfragmented` .DAT with an existing `fragmented` DAT, even of the same size will be `Suspect`.

The destination DAT has to be created in the same manner as the source DAT.
One easy method of re-creating a DB, is using sp_help_revdatabase command. This will create a script for creating DB, including any fragmentation.

Check Books On-Line for more information

Regards

Jasper

----------

