Showing posts with label network. Show all posts
Showing posts with label network. Show all posts

Sunday, March 25, 2012

Copying tables from access to sql server express

I am trying to export a databse from access into sql server express. The access database is on a network and the sql server express is on my local machine.

Could someone give me setp by step instructions please as to how to export the data from the tables into my sql server express.

Thank you very much for your time

Access includes a wizard called the Upsize Wizard that can help you do this. Depending on which version of Access you have, it may be on different menus, but last time I saw it it was under Tools | Database Utilities.

You may have to install the Upsize Wizard if you don't already have the Advanced Wizards installed. Search the Access help file for information about using this tool.

Mike

Thursday, March 22, 2012

Copying tables

I am able to query several different msde databases on my network using
Query Analyzer from my pc. Using SQL Query Analyzer from my pc, I need to
copy a table from a database found on my local msde installation to a
database on another pc's msde installation. I was trying to find the SQL
Query syntax on Books Online but I had no luck. Can you help?
Thanks,
Ademar Nunes
Hi,
See BCP OUT and BCP IN in books online.
Thanks
Hari
SQL Server MVP
"Ademar" <Ademar@.noneofyourbusiness.com> wrote in message
news:uo2iGb6uEHA.1260@.TK2MSFTNGP12.phx.gbl...
>I am able to query several different msde databases on my network using
> Query Analyzer from my pc. Using SQL Query Analyzer from my pc, I need
> to
> copy a table from a database found on my local msde installation to a
> database on another pc's msde installation. I was trying to find the SQL
> Query syntax on Books Online but I had no luck. Can you help?
> --
> Thanks,
> Ademar Nunes
>
|||I did, but I was unable to make it work. I tried again, and I'm still
unable. Can you help?
Thanks,
Ademar Nunes
"Hari Prasad" <hari_prasad_k@.hotmail.com> wrote in message
news:eFagfq8uEHA.568@.TK2MSFTNGP09.phx.gbl...[vbcol=seagreen]
> Hi,
> See BCP OUT and BCP IN in books online.
>
> --
> Thanks
> Hari
> SQL Server MVP
>
> "Ademar" <Ademar@.noneofyourbusiness.com> wrote in message
> news:uo2iGb6uEHA.1260@.TK2MSFTNGP12.phx.gbl...
SQL
>
sql

Monday, March 19, 2012

Copying files between servers

I'm trying to copy files between 2 servers on a local network from within a
SQL Job (and Query Analyzer) using xp_cmdshell.xcopy but get an access
denied message returned.

I'm able to successfully do the copy from within a command window so think
the problem has something to do with using the default SQL Server account
but as yet I don't know how to resolve.

Any help/suggestions would be much appreciated.Am guessng that you are running MS-SQL using the local SYSTEM account.
System does not have access to network devices.

Your two options are to create another account and configure MS-SQL and
agent to use that account. You may beable to get away with just
configuring agent for that but depends on how you are doing the
command.

Or to go into policy editor and allowing the system account to have
netowrk priviledges. This is a major security hole and should not be
done.

Copying detached databases over the network with T-SQL

I have a T-SQL script which deataches and attaches the database. Now here is what I want to do:
I

want to create a SQL Server Job and schedule it to run at a particular

time of the month to Detach all the databases on my local machine and

*Copy all the deatched databases over a network machine* and then

Attach those Database.

All this should be done in T-SQL. I

already have the T-SQLs for Attaching and Detaching. All I need is to

know the T-SQL (example) which will copy the *Detached Databases* from

mu local computer to my Network Computer. How do I achieve that?

Thanks

xp_cmdshell

Executes a given command string as an operating-system command shell and returns any output as rows of text. Grants nonadministrative users permissions to execute xp_cmdshell.

xp_cmdshell 'copy c:\x.mdb y:\x.mdb'

where y: is a mapped network drive

|||You can invoke DOS command through sqlserver (e.g. "copy <source> <\\target>"). You want to take a look at xp_cmdshell in book online for details.|||

aside from using the sql jobs you can use

the "windows scheduler" to

1. detach the database from the source server using sqlcmd

2. use dos command to copy the database

3. use sqlcmd to attach the db to the destination server

I recommend this method over the other

cheers

|||Thank you guys for you replies. I think I may take the path of xp_cmdshell.

joeydj your suggestion looks valid, but I have a question. What is the full command(an example) to detach the database using sqlcmd? Also do I need to run this command on 'Command Prompt'.

Thanks
|||You can use sp_detach_db to detach a database. See BOL for syntax and examples. It is easier doing these type of operations outside the database. Note that in SQL Server 2005 xp_cmdshell is disabled my default on most SKUs & enabling it increases the security risk on the server. So don't use it unless you absolutely need to. Writing a batch file to do these operations is very trivial.|||

for sql2k you can use OSQL the SQLCMD 2005 counterpart

and here's the syntax

c:\ osql -USa -P -S(local)\sql2k -Q"sp_detach_db demodb" -X

where

-Usa --user Sa

-P -- password in my case blank

-S(local)\sql2k --is the server

-Q"sp_detach_db demodb" -- this is the query to detach and watchout for the quotes

-X exit OSQL

sqlcmd has the same syntax except that it handles blank password differently

c:\ SQLCMD -USa -Pmypaswd -S(local)\sql2k -Q"sp_detach_db demodb" -X

you cann use the -E switch for trusted connection

for more help type sqlcmd/? or osql/? on your command prompt

Sunday, March 11, 2012

Copying database over network

Hi,
I'm extremely new to sql , using sql 2000.
I have an application server and a database sitting on a NAS. I would like
to copy the database from the NAS over the network to another server (test
server). I believe with the application server running I would have to detac
h
the data base. If I do not start-up the application server and just do a cop
y
from the NAS to the test server, would this work? and naturally with out
detaching(because there is nothing to detach it from). and I would also like
to give the database a different name. I hope I explaned this correctly. Any
help would be appreciated. Thank You in advance.
Greg newbieConsider using BACKUP and RESTORE. BACKUP lets you backup the database to a
file, which you can move to a different machine, and restore it with a new
name if you prefer, using the RESTORE command. See SQL Server Books Online
for more information and examples on these commands.
--
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"Greg" <Greg@.discussions.microsoft.com> wrote in message
news:E71A2217-AB1E-49CB-9F5D-FBA2B45FAD88@.microsoft.com...
> Hi,
> I'm extremely new to sql , using sql 2000.
> I have an application server and a database sitting on a NAS. I would
> like
> to copy the database from the NAS over the network to another server (test
> server). I believe with the application server running I would have to
> detach
> the data base. If I do not start-up the application server and just do a
> copy
> from the NAS to the test server, would this work? and naturally with out
> detaching(because there is nothing to detach it from). and I would also
> like
> to give the database a different name. I hope I explaned this correctly.
> Any
> help would be appreciated. Thank You in advance.
> --
> Greg newbie

Copying database over network

Hi,
I'm extremely new to sql , using sql 2000.
I have an application server and a database sitting on a NAS. I would like
to copy the database from the NAS over the network to another server (test
server). I believe with the application server running I would have to detach
the data base. If I do not start-up the application server and just do a copy
from the NAS to the test server, would this work? and naturally with out
detaching(because there is nothing to detach it from). and I would also like
to give the database a different name. I hope I explaned this correctly. Any
help would be appreciated. Thank You in advance.
--
Greg newbieConsider using BACKUP and RESTORE. BACKUP lets you backup the database to a
file, which you can move to a different machine, and restore it with a new
name if you prefer, using the RESTORE command. See SQL Server Books Online
for more information and examples on these commands.
--
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"Greg" <Greg@.discussions.microsoft.com> wrote in message
news:E71A2217-AB1E-49CB-9F5D-FBA2B45FAD88@.microsoft.com...
> Hi,
> I'm extremely new to sql , using sql 2000.
> I have an application server and a database sitting on a NAS. I would
> like
> to copy the database from the NAS over the network to another server (test
> server). I believe with the application server running I would have to
> detach
> the data base. If I do not start-up the application server and just do a
> copy
> from the NAS to the test server, would this work? and naturally with out
> detaching(because there is nothing to detach it from). and I would also
> like
> to give the database a different name. I hope I explaned this correctly.
> Any
> help would be appreciated. Thank You in advance.
> --
> Greg newbie

Copying database over network

Hi,
I'm extremely new to sql , using sql 2000.
I have an application server and a database sitting on a NAS. I would like
to copy the database from the NAS over the network to another server (test
server). I believe with the application server running I would have to detach
the data base. If I do not start-up the application server and just do a copy
from the NAS to the test server, would this work? and naturally with out
detaching(because there is nothing to detach it from). and I would also like
to give the database a different name. I hope I explaned this correctly. Any
help would be appreciated. Thank You in advance.
Greg newbie
Consider using BACKUP and RESTORE. BACKUP lets you backup the database to a
file, which you can move to a different machine, and restore it with a new
name if you prefer, using the RESTORE command. See SQL Server Books Online
for more information and examples on these commands.
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"Greg" <Greg@.discussions.microsoft.com> wrote in message
news:E71A2217-AB1E-49CB-9F5D-FBA2B45FAD88@.microsoft.com...
> Hi,
> I'm extremely new to sql , using sql 2000.
> I have an application server and a database sitting on a NAS. I would
> like
> to copy the database from the NAS over the network to another server (test
> server). I believe with the application server running I would have to
> detach
> the data base. If I do not start-up the application server and just do a
> copy
> from the NAS to the test server, would this work? and naturally with out
> detaching(because there is nothing to detach it from). and I would also
> like
> to give the database a different name. I hope I explaned this correctly.
> Any
> help would be appreciated. Thank You in advance.
> --
> Greg newbie

Copying Database from One Server to Another

We recently got a new SQL Server 2000. I'm not really a SQL/Network admin but I was tasked to migrate some of our databases in the SQLSVR7 to SQLSVR2K.
I tried using DTS EXPORT but getting errors. Is there a better way to do this?
Any info would be appreciated.Doing an sp_detach_db on your SQL7 box followed by an sp_attach_db on your SQL2000 box is undoubtedly the easiest & quickest way to migrate your DB, but you will end up with orphaned users in your SQL2000 DB if there were an users in the DB (other than the dbo user, although even that can get orphaned). The orphaned users can be fixed with sp_change_users_login.

Another easy way to do it is by backing up your SQL7 DB and then restoring that backup file to a DB on your SQL2000 box. But, once again, will probably result in orphaned users again.

The reason these two methods work is because both the restore & the sp_attach_db will "convert" the DB format, if necessary, as they go (this will only work for SQL7 to SQL2000 boxes, SQL65 upwards has to go through a DTS package). At least from memory that's how it works (it's been over 3 years since I did it).

DTS is another quite reasonable option - all the DB upgrade wizard does is create a DTS package and run it. The DTS package (once again from a 3+ year old memory) just has a single "copy database" object, or something like that. Personally, I'm not a great DTS fan - I'm more of a T-SQL purist.

Hope that helps.|||You may have to script all of the database, and bcp in/out the data.

This is very timely.

As for the DTS did you click Copy Objects and data betweens SQL Server database?

Lystra|||Another easy way to do it is by backing up your SQL7 DB and then restoring that backup file to a DB on your SQL2000 box. But, once again, will probably result in orphaned users again.

I tried the RESTORE DATABASE option. I copied a complete backup from the SQL7 into a directory of the SQL2K. When I initiate the restore, I get a "Device activation error" (pls see attachment) and is asking me to use "WITH MOVE".

TIF|||You may have to script all of the database, and bcp in/out the data.

This is very timely.

As for the DTS did you click Copy Objects and data betweens SQL Server database?

Lystra

TFYI

What do you mean by "script all of the database"? How can I do that?

Yes, I have that option on a the DTS. It gets an error message pointing to another database (with no owner when I run the sp_helpdp) and the DTS is never completed. I get all the tables but I'm missing the views and all sprocs.|||If you have a skim through SQL Books Online you'll see how to do the restore properly (with the MOVE & REPLACE options). To help you out a bit I just whipped up this SQL batch for you to explain what to do. (I haven't actually executed this batch so it might contain syntax errors (typos) but I can't see any just glancing at it.)

-- Create the DB
create database MySQL2000DB
on
(
name = 'MySQL2000DB_Data',
filename = 'C:\Program Files\Microsoft SQL Server\MSSQL\Data\MySQL2000DB_Data.mdf',
maxsize = 100MB,
filegrowth = 25MB
)
log on
(
name = 'MySQL2000DB_Log',
filename = 'C:\Program Files\Microsoft SQL Server\MSSQL\Data\MySQL2000DB_Log.ldf',
maxsize = 50MB,
filegrowth = 10MB
);

-- Restore from the SQL7 backup
restore database MySQL2000DB from disk = 'C:\Program Files\Microsoft SQL Server\MSSQL\Backup\MySQL7DB.BAK' with
replace,
move 'MySQL7DB_Data' to 'C:\Program Files\Microsoft SQL Server\MSSQL\Data\MySQL2000DB_Data.mdf',
move 'MySQL7DB_Log' to 'C:\Program Files\Microsoft SQL Server\MSSQL\Data\MySQL2000DB_Log.ldf',
recovery;

-- Change the logical file names
use MySQL2000DB;
alter database MySQL2000DB modify file (name = 'MySQL7DB_Data', newname = 'MySQL2000DB_Data');
alter database MySQL2000DB modify file (name = 'MySQL7DB_Log', newname = 'MySQL2000DB_Log');

-- Fix up the orpaned users as reported from sp_change_users_login
exec sp_change_users_login 'report';
go

After you get the list of orphaned users you need to run exec sp_change_users_login 'auto_fix', '<username>' in the MySQL2000DB for each of those users listed when you ran sp_change_users_login 'report' where the '<username>' is the bit you change for each user (not sure how obvious that was to you).

Cheers,|||Thanks for the script. Although I was not successful when I run it, it did point me to the right direction that resolved my problem.

So basically, I used the RESTORE DATABASE tool of the SQL Enterprise Manager. However, I was missing the part where I need to change the path within the physical file name.

Thanks again!