Saturday, February 25, 2012

Copy a table

Can I copy a table from on DB to another - I only want to copy the column
names not the Data
What tool or how should I do this
Thanks
ChrisWhy don't you generate the CREATE TABLE script, and then create the empty
table?
There are lazy ways to do this, e.g. SELECT * INTO newdb.dbo.tablename FROM
OldTable WHERE 1 = 2; but this leaves out many other important things, like
indexes and constraints.
"Chris" <Chris@.discussions.microsoft.com> wrote in message
news:BCD66035-F4BB-46B4-8FCC-4A4D12828918@.microsoft.com...
> Can I copy a table from on DB to another - I only want to copy the column
> names not the Data
>
> What tool or how should I do this
> Thanks
> Chris

Copy a table

Hi,
How do I copy a table in my SQL Server 2000?
Actually, I want to copy MyTable to MyTable2 in MyDataBase, and the records
inside too.
Any help will be appreciated.
JasonCREATE TABLE MyTable2 (...) ;
INSERT INTO MyTable2 (...)
SELECT ...
FROM MyTable ;
Or:
SELECT ...
INTO MyTable2
FROM MyTable ;
In this second case, the constraints won't be copied so you'll still have to
create them yourself.
This is development/admin of course. It isn't normally good practice to
create tables at runtime.
--
David Portas
SQL Server MVP
--
"Jason Huang" <JasonHuang8888@.hotmail.com> wrote in message
news:eqRs4HT1FHA.2964@.TK2MSFTNGP09.phx.gbl...
> Hi,
> How do I copy a table in my SQL Server 2000?
> Actually, I want to copy MyTable to MyTable2 in MyDataBase, and the
> records inside too.
> Any help will be appreciated.
>
> Jason
>|||Hi Jason
David gave you the best technique to copy data from one table to another.
The alternative way of doing this is using DTS.
DTS implements the same technique that David used
--
best Regards,
Chandra
http://chanduas.blogspot.com/
http://www.SQLResource.com/
---
"David Portas" wrote:
> CREATE TABLE MyTable2 (...) ;
> INSERT INTO MyTable2 (...)
> SELECT ...
> FROM MyTable ;
> Or:
> SELECT ...
> INTO MyTable2
> FROM MyTable ;
> In this second case, the constraints won't be copied so you'll still have to
> create them yourself.
> This is development/admin of course. It isn't normally good practice to
> create tables at runtime.
> --
> David Portas
> SQL Server MVP
> --
> "Jason Huang" <JasonHuang8888@.hotmail.com> wrote in message
> news:eqRs4HT1FHA.2964@.TK2MSFTNGP09.phx.gbl...
> > Hi,
> >
> > How do I copy a table in my SQL Server 2000?
> > Actually, I want to copy MyTable to MyTable2 in MyDataBase, and the
> > records inside too.
> > Any help will be appreciated.
> >
> >
> > Jason
> >
>
>|||Thanks David!
The MicroSoft has the "Copy" and "Paste" in many occasions, why don't they
have the "Copy" "Paste" in the SQL Server? Will this be too stupid or I am
too lazy?
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> ¼¶¼g©ó¶l¥ó·s»D:2r6dnX2bm-yyuMreRVnyhA@.giganews.com...
> CREATE TABLE MyTable2 (...) ;
> INSERT INTO MyTable2 (...)
> SELECT ...
> FROM MyTable ;
> Or:
> SELECT ...
> INTO MyTable2
> FROM MyTable ;
> In this second case, the constraints won't be copied so you'll still have
> to create them yourself.
> This is development/admin of course. It isn't normally good practice to
> create tables at runtime.
> --
> David Portas
> SQL Server MVP
> --
> "Jason Huang" <JasonHuang8888@.hotmail.com> wrote in message
> news:eqRs4HT1FHA.2964@.TK2MSFTNGP09.phx.gbl...
>> Hi,
>> How do I copy a table in my SQL Server 2000?
>> Actually, I want to copy MyTable to MyTable2 in MyDataBase, and the
>> records inside too.
>> Any help will be appreciated.
>>
>> Jason
>|||Hi,
There are several reason that microsoft has not provided the facility
of copy and paste because each table has a unique and containe unique
record in terms of name and indexes constraints and many more.
Hope this much is sufficient for u to understand.
from
Doller
Jason Huang wrote:
> Thanks David!
> The MicroSoft has the "Copy" and "Paste" in many occasions, why don't they
> have the "Copy" "Paste" in the SQL Server? Will this be too stupid or I =am
> too lazy?
> "David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> =BC=B6=BCg=A9=F3==B6l=A5=F3=B7s=BBD:2r6dnX2bm-yyuMreRVnyhA@.giganews.com...
> > CREATE TABLE MyTable2 (...) ;
> >
> > INSERT INTO MyTable2 (...)
> > SELECT ...
> > FROM MyTable ;
> >
> > Or:
> >
> > SELECT ...
> > INTO MyTable2
> > FROM MyTable ;
> >
> > In this second case, the constraints won't be copied so you'll still ha=ve
> > to create them yourself.
> >
> > This is development/admin of course. It isn't normally good practice to
> > create tables at runtime.
> >
> > --
> > David Portas
> > SQL Server MVP
> > --
> >
> > "Jason Huang" <JasonHuang8888@.hotmail.com> wrote in message
> > news:eqRs4HT1FHA.2964@.TK2MSFTNGP09.phx.gbl...
> >> Hi,
> >>
> >> How do I copy a table in my SQL Server 2000?
> >> Actually, I want to copy MyTable to MyTable2 in MyDataBase, and the
> >> records inside too.
> >> Any help will be appreciated.
> >>
> >>
> >> Jason
> >>
> >
> >

Copy a Table

In SQL Server 2000, what is the easiest way to make an exact copy of an existing table?
Copy is in the popup menu if you right click on a table but there's no PasteOriginally posted by wey97
In SQL Server 2000, what is the easiest way to make an exact copy of an existing table?

Copy is in the popup menu if you right click on a table but there's no Paste|||[QUOTE][SIZE=1]Originally posted by wey97
In SQL Server 2000, what is the easiest way to make an exact copy of an existing table?

You can do this:

SELECT *
INTO B
FROM A

Notes:
B = TABLE NAME of COPY
A = TABLE NAME of ORIGINAL|||Originally posted by wey97
In SQL Server 2000, what is the easiest way to make an exact copy of an existing table?

Copy is in the popup menu if you right click on a table but there's no Paste

You can do paste in QA (shift+Insert or Cntrl+V)|||To copy only the structure with no data (minimally logged)

select * into newtable from oldtable where 0=1

To copy only the structure with data (minimally logged)

select * into newtable from oldtable

To copy data into an existing table (Fully Logged)

insert into newtable select * from oldtable

To Copy data into an existing table where it doesn't already exist (logged)

insert into newtable select * from oldtable where PK not in (select * from newtable)

HTH|||rhigdon: don't do NOT IN, you'll kill everybody else and possibly the server as well. do left outer join on key_field where key_field is null|||I've heard that before, I'll have to test the IO difference. Have you tested it?|||Right click the database then alltasks->export data
A wizard will appear...
Select the table, put the correct source and destination and at the end choose to drop the existing destination object and not append the data.

It's easy and simple. You can also select to mantain permissions, indexes, etc

Paulo

Originally posted by wey97
In SQL Server 2000, what is the easiest way to make an exact copy of an existing table?

Copy is in the popup menu if you right click on a table but there's no Paste|||yup, many times, plus evidence presented by others, plus ms white papers.|||I'm pretty sure you are right, going to do some testing but if you could share any of those white papers I would appreciate it.|||Well, you can't use:

where PK not in (select * from newtable)

anyway.

I'm sure you meant either:
where PK not in (select PK from newtable)
or:
where not exists (select * from oldtable where old.PK = new.PK)

...both of which generate the same optimizer plan, and oddly enough they ran slightly (insignificantly even) faster than the left outer join method, which threw in an extra step for filtering. Maybe because my test table only had about 20,000 rows.

I've use all three methods and never killed a database with them, but I would be interested in reading any MS white papers as well.

blindman|||I believe you are right, Blindman. MS has been tinkering with this part of the query optimizer, and I think the query plans are largely the same. Imagine my surprise when I was about to storm into a developer's cube to have him re-write such a query, when my own re-write did nothing to help.|||Well, the left join method did use a slightly different plan than the other two, so it could potentially be more (or less) efficient for larger tables. If anybody feels the urge to experiment please post the results.

blindman|||Yes BM, I meant

where PK not in (select PK from newtable)

Well, I am a little confused as I rewrote a query that did a NOT IN query to a 1.4 million row table from a 1000 row table and it cost me a total of 3014 logical reads, when I rewrote it in a left outer join it cost me 3126 logical reads so either I am doing something wrong or the difference is insignificant.

I have searched pretty hard but have been unable to find any MS whitepapers discussing this (although I did find an interesting book in my search that I have now ordered!)|||white papers, articles...this issue goes all the way to 6.0 times where non-clustered field was challenged with IN/NOT IN and the optimizer would revert to table scan in both outer and inner queries. it is possible that in the case of the PK, unless it is non-clustered, not in and let outer join would yield the same result, or close to be the same. this is not the point. the point is that IN clause is less preferrable than exists or left outer join. any more requests for articles?|||I agree with Mcrowley in that I beleive this used to be the case but is no longer true. Not sure what you mean by "any more requests for articles" but I take it to mean you don't want to continue this discussion so guess we'll leave it at that...|||I agree with Mcrowley in that I beleive this used to be the case but is no longer true. Not sure what you mean by "any more requests for articles" but I take it to mean you don't want to continue this discussion so guess we'll leave it at that...

Copy a table

Hi,
How do I copy a table in my SQL Server 2000?
Actually, I want to copy MyTable to MyTable2 in MyDataBase, and the records
inside too.
Any help will be appreciated.
Jason
CREATE TABLE MyTable2 (...) ;
INSERT INTO MyTable2 (...)
SELECT ...
FROM MyTable ;
Or:
SELECT ...
INTO MyTable2
FROM MyTable ;
In this second case, the constraints won't be copied so you'll still have to
create them yourself.
This is development/admin of course. It isn't normally good practice to
create tables at runtime.
David Portas
SQL Server MVP
"Jason Huang" <JasonHuang8888@.hotmail.com> wrote in message
news:eqRs4HT1FHA.2964@.TK2MSFTNGP09.phx.gbl...
> Hi,
> How do I copy a table in my SQL Server 2000?
> Actually, I want to copy MyTable to MyTable2 in MyDataBase, and the
> records inside too.
> Any help will be appreciated.
>
> Jason
>
|||Hi Jason
David gave you the best technique to copy data from one table to another.
The alternative way of doing this is using DTS.
DTS implements the same technique that David used
best Regards,
Chandra
http://chanduas.blogspot.com/
http://www.SQLResource.com/
"David Portas" wrote:

> CREATE TABLE MyTable2 (...) ;
> INSERT INTO MyTable2 (...)
> SELECT ...
> FROM MyTable ;
> Or:
> SELECT ...
> INTO MyTable2
> FROM MyTable ;
> In this second case, the constraints won't be copied so you'll still have to
> create them yourself.
> This is development/admin of course. It isn't normally good practice to
> create tables at runtime.
> --
> David Portas
> SQL Server MVP
> --
> "Jason Huang" <JasonHuang8888@.hotmail.com> wrote in message
> news:eqRs4HT1FHA.2964@.TK2MSFTNGP09.phx.gbl...
>
>
|||Thanks David!
The MicroSoft has the "Copy" and "Paste" in many occasions, why don't they
have the "Copy" "Paste" in the SQL Server? Will this be too stupid or I am
too lazy?
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> glsD:2r6dnX2bm-yyuMreRVnyhA@.giganews.com...
> CREATE TABLE MyTable2 (...) ;
> INSERT INTO MyTable2 (...)
> SELECT ...
> FROM MyTable ;
> Or:
> SELECT ...
> INTO MyTable2
> FROM MyTable ;
> In this second case, the constraints won't be copied so you'll still have
> to create them yourself.
> This is development/admin of course. It isn't normally good practice to
> create tables at runtime.
> --
> David Portas
> SQL Server MVP
> --
> "Jason Huang" <JasonHuang8888@.hotmail.com> wrote in message
> news:eqRs4HT1FHA.2964@.TK2MSFTNGP09.phx.gbl...
>
|||Hi,
There are several reason that microsoft has not provided the facility
of copy and paste because each table has a unique and containe unique
record in terms of name and indexes constraints and many more.
Hope this much is sufficient for u to understand.
from
Doller
Jason Huang wrote:
> Thanks David!
> The MicroSoft has the "Copy" and "Paste" in many occasions, why don't they
> have the "Copy" "Paste" in the SQL Server? Will this be too stupid or I =
am
> too lazy?
> "David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> =BC=B6=BCg=A9=F3=
=B6l=A5=F3=B7s=BBD:2r6dnX2bm-yyuMreRVnyhA@.giganews.com...[vbcol=seagreen]
ve[vbcol=seagreen]

copy a table

Hello all!

How to copy a table in MS SQL Server 2000 without chaning a structure? I
mean, I have one table, which has autoincrement numeric field (ID). When
I copy this table by exporting this table into the same database folder
I loose the specification of the field ID. Now it is not autoincrement
field but usual int field. Is it possible to copy this table without
changing data and structure of a table?

Kindest regards
Thank you
Marcin from Poland

*** Sent via Developersdex http://www.developersdex.com ***Marcin Zmyslowski wrote:
> Hello all!
> How to copy a table in MS SQL Server 2000 without chaning a
> structure? I mean, I have one table, which has autoincrement numeric
> field (ID). When I copy this table by exporting this table into the
> same database folder I loose the specification of the field ID. Now
> it is not autoincrement field but usual int field. Is it possible to
> copy this table without changing data and structure of a table?

With DTS copy object might do the trick. Otherwise, create DDL with QA or
EM, create the new table and then copy the data with "SET IDENTITY_INSERT
your_table ON". HTH

robert|||Insert into table1(columns)
select columns from othertable

Madhivanan

Copy a table

Hi,
How do I copy a table in my SQL Server 2000?
Actually, I want to copy MyTable to MyTable2 in MyDataBase, and the records
inside too.
Any help will be appreciated.
JasonCREATE TABLE MyTable2 (...) ;
INSERT INTO MyTable2 (...)
SELECT ...
FROM MyTable ;
Or:
SELECT ...
INTO MyTable2
FROM MyTable ;
In this second case, the constraints won't be copied so you'll still have to
create them yourself.
This is development/admin of course. It isn't normally good practice to
create tables at runtime.
David Portas
SQL Server MVP
--
"Jason Huang" <JasonHuang8888@.hotmail.com> wrote in message
news:eqRs4HT1FHA.2964@.TK2MSFTNGP09.phx.gbl...
> Hi,
> How do I copy a table in my SQL Server 2000?
> Actually, I want to copy MyTable to MyTable2 in MyDataBase, and the
> records inside too.
> Any help will be appreciated.
>
> Jason
>|||Hi Jason
David gave you the best technique to copy data from one table to another.
The alternative way of doing this is using DTS.
DTS implements the same technique that David used
best Regards,
Chandra
http://chanduas.blogspot.com/
http://www.SQLResource.com/
---
"David Portas" wrote:

> CREATE TABLE MyTable2 (...) ;
> INSERT INTO MyTable2 (...)
> SELECT ...
> FROM MyTable ;
> Or:
> SELECT ...
> INTO MyTable2
> FROM MyTable ;
> In this second case, the constraints won't be copied so you'll still have
to
> create them yourself.
> This is development/admin of course. It isn't normally good practice to
> create tables at runtime.
> --
> David Portas
> SQL Server MVP
> --
> "Jason Huang" <JasonHuang8888@.hotmail.com> wrote in message
> news:eqRs4HT1FHA.2964@.TK2MSFTNGP09.phx.gbl...
>
>|||Thanks David!
The MicroSoft has the "Copy" and "Paste" in many occasions, why don't they
have the "Copy" "Paste" in the SQL Server? Will this be too stupid or I am
too lazy?
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> glsD:2r6dnX2bm-yyuMreRVnyh
A@.giganews.com...
> CREATE TABLE MyTable2 (...) ;
> INSERT INTO MyTable2 (...)
> SELECT ...
> FROM MyTable ;
> Or:
> SELECT ...
> INTO MyTable2
> FROM MyTable ;
> In this second case, the constraints won't be copied so you'll still have
> to create them yourself.
> This is development/admin of course. It isn't normally good practice to
> create tables at runtime.
> --
> David Portas
> SQL Server MVP
> --
> "Jason Huang" <JasonHuang8888@.hotmail.com> wrote in message
> news:eqRs4HT1FHA.2964@.TK2MSFTNGP09.phx.gbl...
>|||Hi,
There are several reason that microsoft has not provided the facility
of copy and paste because each table has a unique and containe unique
record in terms of name and indexes constraints and many more.
Hope this much is sufficient for u to understand.
from
Doller
Jason Huang wrote:
> Thanks David!
> The MicroSoft has the "Copy" and "Paste" in many occasions, why don't they
> have the "Copy" "Paste" in the SQL Server? Will this be too stupid or I =
am
> too lazy?
> "David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> =BC=B6=BCg=A9=F3=
=B6l=A5=F3=B7s=BBD:2r6dnX2bm-yyuMreRVnyhA@.giganews.com...[vbcol=seagreen]
ve[vbcol=seagreen]

Copy a standby/readonly database

Any idea to copy a standby/readonly database. We a have a standby/readonly
DB from logshipping for hot standby and we would like to make a copy of this
standby/readonly DB into a read/write DB in the same server for daily
testing. Thanks in advance!Hi Stephanie
Why not take a backup of the original database and restore it?
John
"stephanie" wrote:
> Any idea to copy a standby/readonly database. We a have a standby/readonly
> DB from logshipping for hot standby and we would like to make a copy of this
> standby/readonly DB into a read/write DB in the same server for daily
> testing. Thanks in advance!|||The original DB is in another server. This is a daily restore in standby
server and the database is about 50GB. it will be heavy load to copy the
files through the network and time consuming to restore the full backup.
"John Bell" wrote:
> Hi Stephanie
> Why not take a backup of the original database and restore it?
> John
>
> "stephanie" wrote:
> > Any idea to copy a standby/readonly database. We a have a standby/readonly
> > DB from logshipping for hot standby and we would like to make a copy of this
> > standby/readonly DB into a read/write DB in the same server for daily
> > testing. Thanks in advance!|||Hi
If you had only wanted a readonly database you could have included it in the
log shipping, but I know of a other way of doing this to make it writable.
You may want to look at Litespeed
http://www.quest.com/litespeed_for_sql_server/ to improve the performance and
compression of your backups.
John
"stephanie" wrote:
> The original DB is in another server. This is a daily restore in standby
> server and the database is about 50GB. it will be heavy load to copy the
> files through the network and time consuming to restore the full backup.
> "John Bell" wrote:
> > Hi Stephanie
> >
> > Why not take a backup of the original database and restore it?
> >
> > John
> >
> >
> >
> > "stephanie" wrote:
> >
> > > Any idea to copy a standby/readonly database. We a have a standby/readonly
> > > DB from logshipping for hot standby and we would like to make a copy of this
> > > standby/readonly DB into a read/write DB in the same server for daily
> > > testing. Thanks in advance!|||This is a multi-part message in MIME format.
--090606030107070301080608
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
stephanie wrote:
> Any idea to copy a standby/readonly database. We a have a standby/readonly
> DB from logshipping for hot standby and we would like to make a copy of this
> standby/readonly DB into a read/write DB in the same server for daily
> testing. Thanks in advance!
>
As John suggest, a backup/restore might do the job. Otherwise you can
look at Replication which can replicate your data to another database.
Regards
Steen Schlüter Persson
Databaseadministrator / Systemadministrator
--090606030107070301080608
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
stephanie wrote:
<blockquote cite="midA6738B2B-39F0-4753-AE5D-ACBD170FDA74@.microsoft.com"
type="cite">
<pre wrap="">Any idea to copy a standby/readonly database. We a have a standby/readonly
DB from logshipping for hot standby and we would like to make a copy of this
standby/readonly DB into a read/write DB in the same server for daily
testing. Thanks in advance!
</pre>
</blockquote>
<font size="-1"><font face="Arial">As John suggest, a backup/restore
might do the job. Otherwise you can look at Replication which can
replicate your data to another database.<br>
<br>
<br>
-- <br>
Regards<br>
Steen Schlüter Persson<br>
Databaseadministrator / Systemadministrator<br>
</font></font>
</body>
</html>
--090606030107070301080608--

Copy a standby/readonly database

Any idea to copy a standby/readonly database. We a have a standby/readonly
DB from logshipping for hot standby and we would like to make a copy of this
standby/readonly DB into a read/write DB in the same server for daily
testing. Thanks in advance!Hi Stephanie
Why not take a backup of the original database and restore it?
John
"stephanie" wrote:

> Any idea to copy a standby/readonly database. We a have a standby/readonl
y
> DB from logshipping for hot standby and we would like to make a copy of th
is
> standby/readonly DB into a read/write DB in the same server for daily
> testing. Thanks in advance!|||The original DB is in another server. This is a daily restore in standby
server and the database is about 50GB. it will be heavy load to copy the
files through the network and time consuming to restore the full backup.
"John Bell" wrote:
[vbcol=seagreen]
> Hi Stephanie
> Why not take a backup of the original database and restore it?
> John
>
> "stephanie" wrote:
>|||Hi
If you had only wanted a readonly database you could have included it in the
log shipping, but I know of a other way of doing this to make it writable.
You may want to look at Litespeed
http://www.quest.com/litespeed_for_sql_server/ to improve the performance an
d
compression of your backups.
John
"stephanie" wrote:
[vbcol=seagreen]
> The original DB is in another server. This is a daily restore in standby
> server and the database is about 50GB. it will be heavy load to copy the
> files through the network and time consuming to restore the full backup.
> "John Bell" wrote:
>|||stephanie wrote:
> Any idea to copy a standby/readonly database. We a have a standby/readonl
y
> DB from logshipping for hot standby and we would like to make a copy of th
is
> standby/readonly DB into a read/write DB in the same server for daily
> testing. Thanks in advance!
>
As John suggest, a backup/restore might do the job. Otherwise you can
look at Replication which can replicate your data to another database.
Regards
Steen Schlüter Persson
Databaseadministrator / Systemadministrator

Copy a SQL 2000 Server database into SQL 2005 Express

I have a database in SQL 2000 that I would like to move to SQL 2005 Express.
I could re-create all of the tables from scratch. Is there an easier way to
copy this database into SQL 2005 Express from SQL 2000 sever. I do not care
about the data, just the design.
Thanks,
Tim
Detach the database from SQL Server2000, copy *.mdf/*.ldf to the computer
where SQL Server2005 installed, attach the files to SQL Server2005.
"dbguru316" <dbguru316@.discussions.microsoft.com> wrote in message
news:18CEF436-E753-44CE-BA56-3AB09D32F248@.microsoft.com...
>I have a database in SQL 2000 that I would like to move to SQL 2005
>Express.
> I could re-create all of the tables from scratch. Is there an easier way
> to
> copy this database into SQL 2005 Express from SQL 2000 sever. I do not
> care
> about the data, just the design.
> Thanks,
> Tim

Copy a SQL 2000 Server database into SQL 2005 Express

I have a database in SQL 2000 that I would like to move to SQL 2005 Express.
I could re-create all of the tables from scratch. Is there an easier way to
copy this database into SQL 2005 Express from SQL 2000 sever. I do not care
about the data, just the design.
Thanks,
TimDetach the database from SQL Server2000, copy *.mdf/*.ldf to the computer
where SQL Server2005 installed, attach the files to SQL Server2005.
"dbguru316" <dbguru316@.discussions.microsoft.com> wrote in message
news:18CEF436-E753-44CE-BA56-3AB09D32F248@.microsoft.com...
>I have a database in SQL 2000 that I would like to move to SQL 2005
>Express.
> I could re-create all of the tables from scratch. Is there an easier way
> to
> copy this database into SQL 2005 Express from SQL 2000 sever. I do not
> care
> about the data, just the design.
> Thanks,
> Tim|||Hi,
Backup SQL Server 2000 database, and restore it
regards
Vt
Knowledge is power;Share it
http://oneplace4sql.blogspot.com
"Norman Yuan" <NotReal@.NotReal.not> wrote in message
news:u3OaRrimHHA.4316@.TK2MSFTNGP06.phx.gbl...
> Detach the database from SQL Server2000, copy *.mdf/*.ldf to the computer
> where SQL Server2005 installed, attach the files to SQL Server2005.
> "dbguru316" <dbguru316@.discussions.microsoft.com> wrote in message
> news:18CEF436-E753-44CE-BA56-3AB09D32F248@.microsoft.com...
>>I have a database in SQL 2000 that I would like to move to SQL 2005
>>Express.
>> I could re-create all of the tables from scratch. Is there an easier way
>> to
>> copy this database into SQL 2005 Express from SQL 2000 sever. I do not
>> care
>> about the data, just the design.
>> Thanks,
>> Tim
>

Copy a SQL 2000 Server database into SQL 2005 Express

I have a database in SQL 2000 that I would like to move to SQL 2005 Express.
I could re-create all of the tables from scratch. Is there an easier way to
copy this database into SQL 2005 Express from SQL 2000 sever. I do not care
about the data, just the design.
Thanks,
TimDetach the database from SQL Server2000, copy *.mdf/*.ldf to the computer
where SQL Server2005 installed, attach the files to SQL Server2005.
"dbguru316" <dbguru316@.discussions.microsoft.com> wrote in message
news:18CEF436-E753-44CE-BA56-3AB09D32F248@.microsoft.com...
>I have a database in SQL 2000 that I would like to move to SQL 2005
>Express.
> I could re-create all of the tables from scratch. Is there an easier way
> to
> copy this database into SQL 2005 Express from SQL 2000 sever. I do not
> care
> about the data, just the design.
> Thanks,
> Tim|||Hi,
Backup SQL Server 2000 database, and restore it
regards
Vt
Knowledge is power;Share it
http://oneplace4sql.blogspot.com
"Norman Yuan" <NotReal@.NotReal.not> wrote in message
news:u3OaRrimHHA.4316@.TK2MSFTNGP06.phx.gbl...
> Detach the database from SQL Server2000, copy *.mdf/*.ldf to the computer
> where SQL Server2005 installed, attach the files to SQL Server2005.
> "dbguru316" <dbguru316@.discussions.microsoft.com> wrote in message
> news:18CEF436-E753-44CE-BA56-3AB09D32F248@.microsoft.com...
>

Copy a row with one change?

Hello. I have a table that has 3 fields as a primary key - JobID (int),
PONumber (char 16) and PORevision (tinyint). I need to make a new row with
the same data except the PORevision field should be increased by 1. I have
tried a few things but nothing seems to work. I could do it in my vb.net
code but I am sure it would be better in the sql database.
Thanks,
Gerry
INSERT INTO YourTable (jobid, ponumber, porevision, other_col, ...)
SELECT jobid, ponumber, porevision+1, other_col, ...
FROM YourTable
WHERE ...
David Portas
SQL Server MVP

Copy a row with one change?

Hello. I have a table that has 3 fields as a primary key - JobID (int),
PONumber (char 16) and PORevision (tinyint). I need to make a new row with
the same data except the PORevision field should be increased by 1. I have
tried a few things but nothing seems to work. I could do it in my vb.net
code but I am sure it would be better in the sql database.
Thanks,
GerryINSERT INTO YourTable (jobid, ponumber, porevision, other_col, ...)
SELECT jobid, ponumber, porevision+1, other_col, ...
FROM YourTable
WHERE ...
David Portas
SQL Server MVP
--

Copy a row with one change?

Hello. I have a table that has 3 fields as a primary key - JobID (int),
PONumber (char 16) and PORevision (tinyint). I need to make a new row with
the same data except the PORevision field should be increased by 1. I have
tried a few things but nothing seems to work. I could do it in my vb.net
code but I am sure it would be better in the sql database.
Thanks,
GerryINSERT INTO YourTable (jobid, ponumber, porevision, other_col, ...)
SELECT jobid, ponumber, porevision+1, other_col, ...
FROM YourTable
WHERE ...
--
David Portas
SQL Server MVP
--|||Or you could make the PORevision field an identity and
the system would do it for you.
>--Original Message--
>Hello. I have a table that has 3 fields as a primary
key - JobID (int),
>PONumber (char 16) and PORevision (tinyint). I need to
make a new row with
>the same data except the PORevision field should be
increased by 1. I have
>tried a few things but nothing seems to work. I could
do it in my vb.net
>code but I am sure it would be better in the sql
database.
>Thanks,
>Gerry
>
>.
>

Copy a row in SQL SERVER 2000

Hello all,
I'd like to INSERT a new row based upon a SELECT of an existing row,
I've tried the below but there's a syntax error:
INSERT INTO TableA VALUES (SELECT * FROM TableA WHERE TableA.PK = 13185)
Also, would this work as it will try to INSERT a field with a
duplicate PK. Any suggesting on how this could be best achived?
Thanks,
JYJon
You almost got it
INSERT INTO TableA SELECT * FROM TableA WHERE TableA.PK = 13185
> Also, would this work as it will try to INSERT a field with a
> duplicate PK. Any suggesting on how this could be best achived?
No it would not. Add an IDENTITY property as a surrogate key
"Jon" <JonMYates@.gmail.com> wrote in message
news:1178702349.126759.189880@.l77g2000hsb.googlegroups.com...
> Hello all,
> I'd like to INSERT a new row based upon a SELECT of an existing row,
> I've tried the below but there's a syntax error:
> INSERT INTO TableA VALUES (SELECT * FROM TableA WHERE TableA.PK => 13185)
> Also, would this work as it will try to INSERT a field with a
> duplicate PK. Any suggesting on how this could be best achived?
> Thanks,
> JY
>|||On 9 May, 10:19, Jon <JonMYa...@.gmail.com> wrote:
> Hello all,
> I'd like to INSERT a new row based upon a SELECT of an existing row,
> I've tried the below but there's a syntax error:
> INSERT INTO TableA VALUES (SELECT * FROM TableA WHERE TableA.PK => 13185)
> Also, would this work as it will try to INSERT a field with a
> duplicate PK. Any suggesting on how this could be best achived?
> Thanks,
> JY
Just leave out VALUES and the brackets:
INSERT INTO TableA (col1, col2, col3)
SELECT col1, col2, col3 FROM ...
It makes no sense to duplicate an entire row. You need to supply new
values for at least the key column(s) of the table in question.
--
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--|||INSERT INTO tabelename (the table you want to copy into)
SELECT * from tablename (the table you want to copy from)
WHERE Field10 = (some condition)

Copy a row in SQL SERVER 2000

Hello all,
I'd like to INSERT a new row based upon a SELECT of an existing row,
I've tried the below but there's a syntax error:
INSERT INTO TableA VALUES (SELECT * FROM TableA WHERE TableA.PK =
13185)
Also, would this work as it will try to INSERT a field with a
duplicate PK. Any suggesting on how this could be best achived?
Thanks,
JY
Jon
You almost got it
INSERT INTO TableA SELECT * FROM TableA WHERE TableA.PK = 13185

> Also, would this work as it will try to INSERT a field with a
> duplicate PK. Any suggesting on how this could be best achived?
No it would not. Add an IDENTITY property as a surrogate key
"Jon" <JonMYates@.gmail.com> wrote in message
news:1178702349.126759.189880@.l77g2000hsb.googlegr oups.com...
> Hello all,
> I'd like to INSERT a new row based upon a SELECT of an existing row,
> I've tried the below but there's a syntax error:
> INSERT INTO TableA VALUES (SELECT * FROM TableA WHERE TableA.PK =
> 13185)
> Also, would this work as it will try to INSERT a field with a
> duplicate PK. Any suggesting on how this could be best achived?
> Thanks,
> JY
>
|||On 9 May, 10:19, Jon <JonMYa...@.gmail.com> wrote:
> Hello all,
> I'd like to INSERT a new row based upon a SELECT of an existing row,
> I've tried the below but there's a syntax error:
> INSERT INTO TableA VALUES (SELECT * FROM TableA WHERE TableA.PK =
> 13185)
> Also, would this work as it will try to INSERT a field with a
> duplicate PK. Any suggesting on how this could be best achived?
> Thanks,
> JY
Just leave out VALUES and the brackets:
INSERT INTO TableA (col1, col2, col3)
SELECT col1, col2, col3 FROM ...
It makes no sense to duplicate an entire row. You need to supply new
values for at least the key column(s) of the table in question.
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
|||INSERT INTO tabelename (the table you want to copy into)
SELECT * from tablename (the table you want to copy from)
WHERE Field10 = (some condition)

Copy a row in SQL SERVER 2000

Hello all,
I'd like to INSERT a new row based upon a SELECT of an existing row,
I've tried the below but there's a syntax error:
INSERT INTO TableA VALUES (SELECT * FROM TableA WHERE TableA.PK =
13185)
Also, would this work as it will try to INSERT a field with a
duplicate PK. Any suggesting on how this could be best achived?
Thanks,
JYJon
You almost got it
INSERT INTO TableA SELECT * FROM TableA WHERE TableA.PK = 13185

> Also, would this work as it will try to INSERT a field with a
> duplicate PK. Any suggesting on how this could be best achived?
No it would not. Add an IDENTITY property as a surrogate key
"Jon" <JonMYates@.gmail.com> wrote in message
news:1178702349.126759.189880@.l77g2000hsb.googlegroups.com...
> Hello all,
> I'd like to INSERT a new row based upon a SELECT of an existing row,
> I've tried the below but there's a syntax error:
> INSERT INTO TableA VALUES (SELECT * FROM TableA WHERE TableA.PK =
> 13185)
> Also, would this work as it will try to INSERT a field with a
> duplicate PK. Any suggesting on how this could be best achived?
> Thanks,
> JY
>|||On 9 May, 10:19, Jon <JonMYa...@.gmail.com> wrote:
> Hello all,
> I'd like to INSERT a new row based upon a SELECT of an existing row,
> I've tried the below but there's a syntax error:
> INSERT INTO TableA VALUES (SELECT * FROM TableA WHERE TableA.PK =
> 13185)
> Also, would this work as it will try to INSERT a field with a
> duplicate PK. Any suggesting on how this could be best achived?
> Thanks,
> JY
Just leave out VALUES and the brackets:
INSERT INTO TableA (col1, col2, col3)
SELECT col1, col2, col3 FROM ...
It makes no sense to duplicate an entire row. You need to supply new
values for at least the key column(s) of the table in question.
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--|||INSERT INTO tabelename (the table you want to copy into)
SELECT * from tablename (the table you want to copy from)
WHERE Field10 = (some condition)

copy a report

I have a report that I would like to make a copy of so that I can use a
different dataset. how can i do this?I find it easier to do items like this outside of VS (or Report Builder).
Simply copy the rdl file in Windows Explorer, then "Add an Existing Item" to
your report project. You can then you can modify your dataset.
"Dean" wrote:
> I have a report that I would like to make a copy of so that I can use a
> different dataset. how can i do this?
>
>|||Yeah,
Or alternatively... View the code, copy all.. Create a new report... View
the code... Paste..
Done.
"David" <David@.discussions.microsoft.com> wrote in message
news:A9520993-F2C4-4A7F-8319-B780EFD7CC73@.microsoft.com...
>I find it easier to do items like this outside of VS (or Report Builder).
> Simply copy the rdl file in Windows Explorer, then "Add an Existing Item"
> to
> your report project. You can then you can modify your dataset.
> "Dean" wrote:
>> I have a report that I would like to make a copy of so that I can use a
>> different dataset. how can i do this?
>>

copy a record?

Hi,
I need to copy a record in a table that has an identity column. Plus,
I want to copy this record without using a column list in the SQL
statement.
So I searched the net, came up with an elegant solution:
INSERT INTO <table>
SELECT *
FROM table WHERE (table.ID = @.objID)
however, when tried that I received:
Error 8101 An explicit value for the identity column in table can only
be specified when a column list is used and IDENTITY_INSERT is ON
So searched again and had the following answers:
"...Before your SQL Statement:
SET IDENTITY_INSERT <tablename> ON
" and someone added:
"...
You need a column list for your INSERT statement:
INSERT t2 (
[id], [first], [org], [rest], [aux] ) SELECT
[ie], [first], [org], [rest], [aux] FROM t1
..."
BUT - I have to ask:
what if I want to insert without having to use a column list? if
i use a column list, then every time a column is added, modified or
deleted I need to change this store procedure too, which results in
doubling maintenance costs.
any ideas? how can I copy a record without using a named column
list?
Thanks very much for ANY idea,
Lior<liormessinger@.gmail.com> wrote in message
news:1188944370.602740.106640@.k79g2000hse.googlegroups.com...
> I need to copy a record in a table that has an identity column. Plus,
> I want to copy this record without using a column list in the SQL
> statement.
Generate the SQL (including the column list) yourself at runtime
Liz
> So I searched the net, came up with an elegant solution:
> INSERT INTO <table>
> SELECT *
> FROM table WHERE (table.ID = @.objID)
> however, when tried that I received:
> Error 8101 An explicit value for the identity column in table can only
> be specified when a column list is used and IDENTITY_INSERT is ON
> So searched again and had the following answers:
> "...Before your SQL Statement:
> SET IDENTITY_INSERT <tablename> ON
> " and someone added:
> "...
> You need a column list for your INSERT statement:
> INSERT t2 (
> [id], [first], [org], [rest], [aux] ) SELECT
> [ie], [first], [org], [rest], [aux] FROM t1
> ..."
> BUT - I have to ask:
> what if I want to insert without having to use a column list? if
> i use a column list, then every time a column is added, modified or
> deleted I need to change this store procedure too, which results in
> doubling maintenance costs.
> any ideas? how can I copy a record without using a named column
> list?|||FWIW, anyone who submits SQL, or SPL that has INSERT/UPDATE statements that
do not have column lists, gets their code back, I won't even allow it on QA.
The reason is maintenance. If I add a column to a table, the code will
break, and then I have to dig it out of the system to do a hot-fix.
<liormessinger@.gmail.com> wrote in message
news:1188944370.602740.106640@.k79g2000hse.googlegroups.com...
> Hi,
> I need to copy a record in a table that has an identity column. Plus,
> I want to copy this record without using a column list in the SQL
> statement.
> So I searched the net, came up with an elegant solution:
> INSERT INTO <table>
> SELECT *
> FROM table WHERE (table.ID = @.objID)
> however, when tried that I received:
> Error 8101 An explicit value for the identity column in table can only
> be specified when a column list is used and IDENTITY_INSERT is ON
> So searched again and had the following answers:
> "...Before your SQL Statement:
> SET IDENTITY_INSERT <tablename> ON
> " and someone added:
> "...
> You need a column list for your INSERT statement:
> INSERT t2 (
> [id], [first], [org], [rest], [aux] ) SELECT
> [ie], [first], [org], [rest], [aux] FROM t1
> ..."
> BUT - I have to ask:
> what if I want to insert without having to use a column list? if
> i use a column list, then every time a column is added, modified or
> deleted I need to change this store procedure too, which results in
> doubling maintenance costs.
> any ideas? how can I copy a record without using a named column
> list?
> Thanks very much for ANY idea,
> Lior
>|||WHY do you not want to do a column list' I can think if several reasons
why you SHOULD do one.
--
TheSQLGuru
President
Indicium Resources, Inc.
<liormessinger@.gmail.com> wrote in message
news:1188944370.602740.106640@.k79g2000hse.googlegroups.com...
> Hi,
> I need to copy a record in a table that has an identity column. Plus,
> I want to copy this record without using a column list in the SQL
> statement.
> So I searched the net, came up with an elegant solution:
> INSERT INTO <table>
> SELECT *
> FROM table WHERE (table.ID = @.objID)
> however, when tried that I received:
> Error 8101 An explicit value for the identity column in table can only
> be specified when a column list is used and IDENTITY_INSERT is ON
> So searched again and had the following answers:
> "...Before your SQL Statement:
> SET IDENTITY_INSERT <tablename> ON
> " and someone added:
> "...
> You need a column list for your INSERT statement:
> INSERT t2 (
> [id], [first], [org], [rest], [aux] ) SELECT
> [ie], [first], [org], [rest], [aux] FROM t1
> ..."
> BUT - I have to ask:
> what if I want to insert without having to use a column list? if
> i use a column list, then every time a column is added, modified or
> deleted I need to change this store procedure too, which results in
> doubling maintenance costs.
> any ideas? how can I copy a record without using a named column
> list?
> Thanks very much for ANY idea,
> Lior
>|||Thanks to all answers. the reason I DONT want a coloumn list is to
avoid having the code breaks when I add/modify/delete a column. I want
to minimize the explicit names of columns and to have something like
INSERT INTO <table>
SELECT *
FROM table WHERE (table.ID = @.objID)
See? Here I have only one column name. therefore, less maintainence.
does it make sense? thanks for any ideas
thanks,
Lior
Sep 5, 9:05 am, "TheSQLGuru" <kgbo...@.earthlink.net> wrote:
> WHY do you not want to do a column list' I can think if several reasons
> why you SHOULD do one.
w
> --
> TheSQLGuru
> President
> Indicium Resources, Inc.
> <liormessin...@.gmail.com> wrote in message
> news:1188944370.602740.106640@.k79g2000hse.googlegroups.com...
> > Hi,
> > I need tocopy a recordin a table that has an identity column. Plus,
> > I want to copy this record without using a column list in the SQL
> > statement.
> > So I searched the net, came up with an elegant solution:
> > INSERT INTO <table>
> > SELECT *
> > FROM table WHERE (table.ID = @.objID)
> > however, when tried that I received:
> > Error 8101 An explicit value for the identity column in table can only
> > be specified when a column list is used and IDENTITY_INSERT is ON
> > So searched again and had the following answers:
> > "...Before your SQL Statement:
> > SET IDENTITY_INSERT <tablename> ON
> > " and someone added:
> > "...
> > You need a column list for your INSERT statement:
> > INSERT t2 (
> > [id], [first], [org], [rest], [aux] ) SELECT
> > [ie], [first], [org], [rest], [aux] FROM t1
> > ..."
> > BUT - I have to ask:
> > what if I want to insert without having to use a column list? if
> > i use a column list, then every time a column is added, modified or
> > deleted I need to change this store procedure too, which results in
> > doubling maintenance costs.
> > any ideas? how can Icopy a recordwithout using a named column
> > list?
> > Thanks very much for ANY idea,
> > Lior|||Actually, very interesting - here is a great thread I found about the
subject. My problem is exactly as Chris's
http://groups.google.com/group/microsoft.public.sqlserver.programming/browse_thread/thread/e59a1ef42bafeff9/23480e2a7fc6dc7a?lnk=gst&q=copy+a+record&rnum=2#23480e2a7fc6dc7a|||The real root problem here seems to be your developement process!! If you
aren't doing an impact analysis when you alter a table and making necessary
modifications to your code then that needs to be rectified, IMHO. BTW, you
can STILL make things work by simply using NULLable columns and/or defining
defaults for your tables, right?
--
TheSQLGuru
President
Indicium Resources, Inc.
<liormessinger@.gmail.com> wrote in message
news:1189040443.208198.139120@.o80g2000hse.googlegroups.com...
> Thanks to all answers. the reason I DONT want a coloumn list is to
> avoid having the code breaks when I add/modify/delete a column. I want
> to minimize the explicit names of columns and to have something like
> INSERT INTO <table>
> SELECT *
> FROM table WHERE (table.ID = @.objID)
> See? Here I have only one column name. therefore, less maintainence.
> does it make sense? thanks for any ideas
> thanks,
> Lior
>
>
>
>
> Sep 5, 9:05 am, "TheSQLGuru" <kgbo...@.earthlink.net> wrote:
>> WHY do you not want to do a column list' I can think if several reasons
>> why you SHOULD do one.
> w
>> --
>> TheSQLGuru
>> President
>> Indicium Resources, Inc.
>> <liormessin...@.gmail.com> wrote in message
>> news:1188944370.602740.106640@.k79g2000hse.googlegroups.com...
>> > Hi,
>> > I need tocopy a recordin a table that has an identity column. Plus,
>> > I want to copy this record without using a column list in the SQL
>> > statement.
>> > So I searched the net, came up with an elegant solution:
>> > INSERT INTO <table>
>> > SELECT *
>> > FROM table WHERE (table.ID = @.objID)
>> > however, when tried that I received:
>> > Error 8101 An explicit value for the identity column in table can only
>> > be specified when a column list is used and IDENTITY_INSERT is ON
>> > So searched again and had the following answers:
>> > "...Before your SQL Statement:
>> > SET IDENTITY_INSERT <tablename> ON
>> > " and someone added:
>> > "...
>> > You need a column list for your INSERT statement:
>> > INSERT t2 (
>> > [id], [first], [org], [rest], [aux] ) SELECT
>> > [ie], [first], [org], [rest], [aux] FROM t1
>> > ..."
>> > BUT - I have to ask:
>> > what if I want to insert without having to use a column list? if
>> > i use a column list, then every time a column is added, modified or
>> > deleted I need to change this store procedure too, which results in
>> > doubling maintenance costs.
>> > any ideas? how can Icopy a recordwithout using a named column
>> > list?
>> > Thanks very much for ANY idea,
>> > Lior
>|||On 4 Sep, 23:19, liormessin...@.gmail.com wrote:
> Hi,
> I need to copy a record in a table that has an identity column. Plus,
> I want to copy this record without using a column list in the SQL
> statement.
> So I searched the net, came up with an elegant solution:
> INSERT INTO <table>
> SELECT *
> FROM table WHERE (table.ID = @.objID)
> however, when tried that I received:
> Error 8101 An explicit value for the identity column in table can only
> be specified when a column list is used and IDENTITY_INSERT is ON
> So searched again and had the following answers:
> "...Before your SQL Statement:
> SET IDENTITY_INSERT <tablename> ON
> " and someone added:
> "...
> You need a column list for your INSERT statement:
> INSERT t2 (
> [id], [first], [org], [rest], [aux] ) SELECT
> [ie], [first], [org], [rest], [aux] FROM t1
> ..."
> BUT - I have to ask:
> what if I want to insert without having to use a column list? if
> i use a column list, then every time a column is added, modified or
> deleted I need to change this store procedure too, which results in
> doubling maintenance costs.
> any ideas? how can I copy a record without using a named column
> list?
> Thanks very much for ANY idea,
> Lior
Please do NOT multi-post. You have several replies in the
microsoft.public.sqlserver.programming newsgroup.
Posting independently to multiple groups wastes everyones time and
makes it harder for people to help you.
--
David Portas|||On Sep 6, 7:00 am, liormessin...@.gmail.com wrote:
> Thanks to all answers. the reason I DONT want a coloumn list is to
> avoid having the code breaks when I add/modify/delete a column. I want
> to minimize the explicit names of columns and to have something like
> INSERT INTO <table>
> SELECT *
> FROM table WHERE (table.ID = @.objID)
> See? Here I have only one column name. therefore, less maintainence.
> does it make sense? thanks for any ideas
> thanks,
> Lior
> Sep 5, 9:05 am, "TheSQLGuru" <kgbo...@.earthlink.net> wrote:
>
> > WHY do you not want to do a column list' I can think if several reasons
> > why you SHOULD do one.
> w
> > --
> > TheSQLGuru
> > President
> > Indicium Resources, Inc.
> > <liormessin...@.gmail.com> wrote in message
> >news:1188944370.602740.106640@.k79g2000hse.googlegroups.com...
> > > Hi,
> > > I need tocopy a recordin a table that has an identity column. Plus,
> > > I want to copy this record without using a column list in the SQL
> > > statement.
> > > So I searched the net, came up with an elegant solution:
> > > INSERT INTO <table>
> > > SELECT *
> > > FROM table WHERE (table.ID = @.objID)
> > > however, when tried that I received:
> > > Error 8101 An explicit value for the identity column in table can only
> > > be specified when a column list is used and IDENTITY_INSERT is ON
> > > So searched again and had the following answers:
> > > "...Before your SQL Statement:
> > > SET IDENTITY_INSERT <tablename> ON
> > > " and someone added:
> > > "...
> > > You need a column list for your INSERT statement:
> > > INSERT t2 (
> > > [id], [first], [org], [rest], [aux] ) SELECT
> > > [ie], [first], [org], [rest], [aux] FROM t1
> > > ..."
> > > BUT - I have to ask:
> > > what if I want to insert without having to use a column list? if
> > > i use a column list, then every time a column is added, modified or
> > > deleted I need to change this store procedure too, which results in
> > > doubling maintenance costs.
> > > any ideas? how can Icopy a recordwithout using a named column
> > > list?
> > > Thanks very much for ANY idea,
> > > Lior- Hide quoted text -
> - Show quoted text -
When you do not explicitly mention the column it can cause very hard
to find bugs where wrong columns get populated! Tust me on this
because it happened to me. Also, if you add/delete/modify a column,
your code will break when you do not have a column list.

Copy a record from one table to another?

Hello,

Is there a way of copying/moving a record from one table to another identical table on the same database using ADO.NET
I can obviously do it the long way (retrieving a record, then pushing it up using a second SQL command)
I was just wondering if there is a way to do it in one database hit using some kind of cool SQL function.Look at the insert ... select statement in Books on Line

insert into table1
(field1, field2)
select
field1, field2
from table2
where recordid = 1|||If there are no identity fields involved, you can exclude the field names:

INSERT INTO table1
SELECT * FROM table2
WHERE id = 3

copy a job from one database to another

Hi, new to sql server 2000, wondering if there is a easy way to copy a job
from my test database to production database...they are on same instance...
Thanks,
GerryYou can right click on the Job, select [All Tasks], and select [Generate SQL
Script].
Then edit the file, changing the name of the server, and run the script on
the Production server.
--
Arnie Rowland
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
"gerry m" <gerrym@.discussions.microsoft.com> wrote in message
news:706D9450-E992-4B7C-811F-745E3DA3C270@.microsoft.com...
> Hi, new to sql server 2000, wondering if there is a easy way to copy a job
> from my test database to production database...they are on same
> instance...
> Thanks,
> Gerry|||Thank you Anne...I will give this a try tonite...
Gerry
"Arnie Rowland" wrote:
> You can right click on the Job, select [All Tasks], and select [Generate SQL
> Script].
> Then edit the file, changing the name of the server, and run the script on
> the Production server.
> --
> Arnie Rowland
> Most good judgment comes from experience.
> Most experience comes from bad judgment.
> - Anonymous
>
> "gerry m" <gerrym@.discussions.microsoft.com> wrote in message
> news:706D9450-E992-4B7C-811F-745E3DA3C270@.microsoft.com...
> > Hi, new to sql server 2000, wondering if there is a easy way to copy a job
> > from my test database to production database...they are on same
> > instance...
> >
> > Thanks,
> >
> > Gerry
>
>|||Anne, is there a way to keep it structured with steps and to set up on a new
schedule (like it is in the test db?)
Thanks,
Gerry
"gerry m" wrote:
> Thank you Anne...I will give this a try tonite...
> Gerry
> "Arnie Rowland" wrote:
> > You can right click on the Job, select [All Tasks], and select [Generate SQL
> > Script].
> >
> > Then edit the file, changing the name of the server, and run the script on
> > the Production server.
> >
> > --
> > Arnie Rowland
> > Most good judgment comes from experience.
> > Most experience comes from bad judgment.
> > - Anonymous
> >
> >
> > "gerry m" <gerrym@.discussions.microsoft.com> wrote in message
> > news:706D9450-E992-4B7C-811F-745E3DA3C270@.microsoft.com...
> > > Hi, new to sql server 2000, wondering if there is a easy way to copy a job
> > > from my test database to production database...they are on same
> > > instance...
> > >
> > > Thanks,
> > >
> > > Gerry
> >
> >
> >|||The script will contain the same steps and the same schedule. If you need to
change the schedule, it is best done after the Job is in the new server.
--
Arnie Rowland
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
"gerry m" <gerrym@.discussions.microsoft.com> wrote in message
news:CF0C8A51-3738-4DC2-A508-36DC1C2FE1AB@.microsoft.com...
> Anne, is there a way to keep it structured with steps and to set up on a
> new
> schedule (like it is in the test db?)
> Thanks,
> Gerry
> "gerry m" wrote:
>> Thank you Anne...I will give this a try tonite...
>> Gerry
>> "Arnie Rowland" wrote:
>> > You can right click on the Job, select [All Tasks], and select
>> > [Generate SQL
>> > Script].
>> >
>> > Then edit the file, changing the name of the server, and run the script
>> > on
>> > the Production server.
>> >
>> > --
>> > Arnie Rowland
>> > Most good judgment comes from experience.
>> > Most experience comes from bad judgment.
>> > - Anonymous
>> >
>> >
>> > "gerry m" <gerrym@.discussions.microsoft.com> wrote in message
>> > news:706D9450-E992-4B7C-811F-745E3DA3C270@.microsoft.com...
>> > > Hi, new to sql server 2000, wondering if there is a easy way to copy
>> > > a job
>> > > from my test database to production database...they are on same
>> > > instance...
>> > >
>> > > Thanks,
>> > >
>> > > Gerry
>> >
>> >
>> >|||Arnie, I am a bit confused...I generated the script and edited it for the new
database name, but am at a loss to work all that script into the 'create new
job' box without having to break it all down into steps
"Arnie Rowland" wrote:
> The script will contain the same steps and the same schedule. If you need to
> change the schedule, it is best done after the Job is in the new server.
> --
> Arnie Rowland
> Most good judgment comes from experience.
> Most experience comes from bad judgment.
> - Anonymous
>
> "gerry m" <gerrym@.discussions.microsoft.com> wrote in message
> news:CF0C8A51-3738-4DC2-A508-36DC1C2FE1AB@.microsoft.com...
> > Anne, is there a way to keep it structured with steps and to set up on a
> > new
> > schedule (like it is in the test db?)
> >
> > Thanks,
> >
> > Gerry
> >
> > "gerry m" wrote:
> >
> >> Thank you Anne...I will give this a try tonite...
> >>
> >> Gerry
> >>
> >> "Arnie Rowland" wrote:
> >>
> >> > You can right click on the Job, select [All Tasks], and select
> >> > [Generate SQL
> >> > Script].
> >> >
> >> > Then edit the file, changing the name of the server, and run the script
> >> > on
> >> > the Production server.
> >> >
> >> > --
> >> > Arnie Rowland
> >> > Most good judgment comes from experience.
> >> > Most experience comes from bad judgment.
> >> > - Anonymous
> >> >
> >> >
> >> > "gerry m" <gerrym@.discussions.microsoft.com> wrote in message
> >> > news:706D9450-E992-4B7C-811F-745E3DA3C270@.microsoft.com...
> >> > > Hi, new to sql server 2000, wondering if there is a easy way to copy
> >> > > a job
> >> > > from my test database to production database...they are on same
> >> > > instance...
> >> > >
> >> > > Thanks,
> >> > >
> >> > > Gerry
> >> >
> >> >
> >> >
>
>|||You take the script that was generated, and you execute the entire script in
Query Analyzer. It will then recreate the Job and you can edit using
Enterprise Manager.
--
Arnie Rowland
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
"gerry m" <gerrym@.discussions.microsoft.com> wrote in message
news:1639671C-E028-4910-AA43-38012BB3AFFC@.microsoft.com...
> Arnie, I am a bit confused...I generated the script and edited it for the
> new
> database name, but am at a loss to work all that script into the 'create
> new
> job' box without having to break it all down into steps
> "Arnie Rowland" wrote:
>> The script will contain the same steps and the same schedule. If you need
>> to
>> change the schedule, it is best done after the Job is in the new server.
>> --
>> Arnie Rowland
>> Most good judgment comes from experience.
>> Most experience comes from bad judgment.
>> - Anonymous
>>
>> "gerry m" <gerrym@.discussions.microsoft.com> wrote in message
>> news:CF0C8A51-3738-4DC2-A508-36DC1C2FE1AB@.microsoft.com...
>> > Anne, is there a way to keep it structured with steps and to set up on
>> > a
>> > new
>> > schedule (like it is in the test db?)
>> >
>> > Thanks,
>> >
>> > Gerry
>> >
>> > "gerry m" wrote:
>> >
>> >> Thank you Anne...I will give this a try tonite...
>> >>
>> >> Gerry
>> >>
>> >> "Arnie Rowland" wrote:
>> >>
>> >> > You can right click on the Job, select [All Tasks], and select
>> >> > [Generate SQL
>> >> > Script].
>> >> >
>> >> > Then edit the file, changing the name of the server, and run the
>> >> > script
>> >> > on
>> >> > the Production server.
>> >> >
>> >> > --
>> >> > Arnie Rowland
>> >> > Most good judgment comes from experience.
>> >> > Most experience comes from bad judgment.
>> >> > - Anonymous
>> >> >
>> >> >
>> >> > "gerry m" <gerrym@.discussions.microsoft.com> wrote in message
>> >> > news:706D9450-E992-4B7C-811F-745E3DA3C270@.microsoft.com...
>> >> > > Hi, new to sql server 2000, wondering if there is a easy way to
>> >> > > copy
>> >> > > a job
>> >> > > from my test database to production database...they are on same
>> >> > > instance...
>> >> > >
>> >> > > Thanks,
>> >> > >
>> >> > > Gerry
>> >> >
>> >> >
>> >> >
>>|||Jobs are server specific, not database. So, you may want to script the job
in Enterprise Manager (right click on the job in Enterprise Manager, to get
to the scripting options) and recreate the job with a different name (you
have to edit the sp_add_job in the script). Once the job is recreated with a
different name, you can edit it to change the database context.
--
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"gerry m" <gerrym@.discussions.microsoft.com> wrote in message
news:706D9450-E992-4B7C-811F-745E3DA3C270@.microsoft.com...
> Hi, new to sql server 2000, wondering if there is a easy way to copy a job
> from my test database to production database...they are on same
> instance...
> Thanks,
> Gerry|||Arnie, thanks for your help and time, this worked fine.
Thanks again,
Gerry
"Arnie Rowland" wrote:
> You take the script that was generated, and you execute the entire script in
> Query Analyzer. It will then recreate the Job and you can edit using
> Enterprise Manager.
> --
> Arnie Rowland
> Most good judgment comes from experience.
> Most experience comes from bad judgment.
> - Anonymous
>
> "gerry m" <gerrym@.discussions.microsoft.com> wrote in message
> news:1639671C-E028-4910-AA43-38012BB3AFFC@.microsoft.com...
> > Arnie, I am a bit confused...I generated the script and edited it for the
> > new
> > database name, but am at a loss to work all that script into the 'create
> > new
> > job' box without having to break it all down into steps
> >
> > "Arnie Rowland" wrote:
> >
> >> The script will contain the same steps and the same schedule. If you need
> >> to
> >> change the schedule, it is best done after the Job is in the new server.
> >>
> >> --
> >> Arnie Rowland
> >> Most good judgment comes from experience.
> >> Most experience comes from bad judgment.
> >> - Anonymous
> >>
> >>
> >> "gerry m" <gerrym@.discussions.microsoft.com> wrote in message
> >> news:CF0C8A51-3738-4DC2-A508-36DC1C2FE1AB@.microsoft.com...
> >> > Anne, is there a way to keep it structured with steps and to set up on
> >> > a
> >> > new
> >> > schedule (like it is in the test db?)
> >> >
> >> > Thanks,
> >> >
> >> > Gerry
> >> >
> >> > "gerry m" wrote:
> >> >
> >> >> Thank you Anne...I will give this a try tonite...
> >> >>
> >> >> Gerry
> >> >>
> >> >> "Arnie Rowland" wrote:
> >> >>
> >> >> > You can right click on the Job, select [All Tasks], and select
> >> >> > [Generate SQL
> >> >> > Script].
> >> >> >
> >> >> > Then edit the file, changing the name of the server, and run the
> >> >> > script
> >> >> > on
> >> >> > the Production server.
> >> >> >
> >> >> > --
> >> >> > Arnie Rowland
> >> >> > Most good judgment comes from experience.
> >> >> > Most experience comes from bad judgment.
> >> >> > - Anonymous
> >> >> >
> >> >> >
> >> >> > "gerry m" <gerrym@.discussions.microsoft.com> wrote in message
> >> >> > news:706D9450-E992-4B7C-811F-745E3DA3C270@.microsoft.com...
> >> >> > > Hi, new to sql server 2000, wondering if there is a easy way to
> >> >> > > copy
> >> >> > > a job
> >> >> > > from my test database to production database...they are on same
> >> >> > > instance...
> >> >> > >
> >> >> > > Thanks,
> >> >> > >
> >> >> > > Gerry
> >> >> >
> >> >> >
> >> >> >
> >>
> >>
> >>
>
>

copy a job from one database to another

Hi, new to sql server 2000, wondering if there is a easy way to copy a job
from my test database to production database...they are on same instance...
Thanks,
GerryYou can right click on the Job, select [All Tasks], and select [Gene
rate SQL
Script].
Then edit the file, changing the name of the server, and run the script on
the Production server.
Arnie Rowland
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
"gerry m" <gerrym@.discussions.microsoft.com> wrote in message
news:706D9450-E992-4B7C-811F-745E3DA3C270@.microsoft.com...
> Hi, new to sql server 2000, wondering if there is a easy way to copy a job
> from my test database to production database...they are on same
> instance...
> Thanks,
> Gerry|||Thank you Anne...I will give this a try tonite...
Gerry
"Arnie Rowland" wrote:

> You can right click on the Job, select [All Tasks], and select [Ge
nerate SQL
> Script].
> Then edit the file, changing the name of the server, and run the script on
> the Production server.
> --
> Arnie Rowland
> Most good judgment comes from experience.
> Most experience comes from bad judgment.
> - Anonymous
>
> "gerry m" <gerrym@.discussions.microsoft.com> wrote in message
> news:706D9450-E992-4B7C-811F-745E3DA3C270@.microsoft.com...
>
>|||Anne, is there a way to keep it structured with steps and to set up on a new
schedule (like it is in the test db?)
Thanks,
Gerry
"gerry m" wrote:
[vbcol=seagreen]
> Thank you Anne...I will give this a try tonite...
> Gerry
> "Arnie Rowland" wrote:
>|||The script will contain the same steps and the same schedule. If you need to
change the schedule, it is best done after the Job is in the new server.
Arnie Rowland
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
"gerry m" <gerrym@.discussions.microsoft.com> wrote in message
news:CF0C8A51-3738-4DC2-A508-36DC1C2FE1AB@.microsoft.com...[vbcol=seagreen]
> Anne, is there a way to keep it structured with steps and to set up on a
> new
> schedule (like it is in the test db?)
> Thanks,
> Gerry
> "gerry m" wrote:
>|||Arnie, I am a bit confused...I generated the script and edited it for the ne
w
database name, but am at a loss to work all that script into the 'create new
job' box without having to break it all down into steps
"Arnie Rowland" wrote:

> The script will contain the same steps and the same schedule. If you need
to
> change the schedule, it is best done after the Job is in the new server.
> --
> Arnie Rowland
> Most good judgment comes from experience.
> Most experience comes from bad judgment.
> - Anonymous
>
> "gerry m" <gerrym@.discussions.microsoft.com> wrote in message
> news:CF0C8A51-3738-4DC2-A508-36DC1C2FE1AB@.microsoft.com...
>
>|||You take the script that was generated, and you execute the entire script in
Query Analyzer. It will then recreate the Job and you can edit using
Enterprise Manager.
Arnie Rowland
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
"gerry m" <gerrym@.discussions.microsoft.com> wrote in message
news:1639671C-E028-4910-AA43-38012BB3AFFC@.microsoft.com...[vbcol=seagreen]
> Arnie, I am a bit confused...I generated the script and edited it for the
> new
> database name, but am at a loss to work all that script into the 'create
> new
> job' box without having to break it all down into steps
> "Arnie Rowland" wrote:
>|||Jobs are server specific, not database. So, you may want to script the job
in Enterprise Manager (right click on the job in Enterprise Manager, to get
to the scripting options) and recreate the job with a different name (you
have to edit the sp_add_job in the script). Once the job is recreated with a
different name, you can edit it to change the database context.
--
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"gerry m" <gerrym@.discussions.microsoft.com> wrote in message
news:706D9450-E992-4B7C-811F-745E3DA3C270@.microsoft.com...
> Hi, new to sql server 2000, wondering if there is a easy way to copy a job
> from my test database to production database...they are on same
> instance...
> Thanks,
> Gerry|||Arnie, thanks for your help and time, this worked fine.
Thanks again,
Gerry
"Arnie Rowland" wrote:

> You take the script that was generated, and you execute the entire script
in
> Query Analyzer. It will then recreate the Job and you can edit using
> Enterprise Manager.
> --
> Arnie Rowland
> Most good judgment comes from experience.
> Most experience comes from bad judgment.
> - Anonymous
>
> "gerry m" <gerrym@.discussions.microsoft.com> wrote in message
> news:1639671C-E028-4910-AA43-38012BB3AFFC@.microsoft.com...
>
>

copy a job

Hi,
I need to copy a job to the same istance of Microsoft SQL 2000 (SP4). I'd
like to rename it modify some parameters and re-schedule the database.
I can't find nothing for copy or duplicate the job.. any help? by Enterprise
Manager and Transact-SQL?
Thank's
AndreaRight-click the job, select All Tasks > Generate SQL script. Specify a
filename and click OK.
This generates a script which you can modify and then run to create a
new job.
David Portas
SQL Server MVP
--

copy a job

Hi,
I need to copy a job to the same istance of Microsoft SQL 2000 (SP4). I'd
like to rename it modify some parameters and re-schedule the database.
I can't find nothing for copy or duplicate the job.. any help? by Enterprise
Manager and Transact-SQL?
Thank's
Andrea
Right-click the job, select All Tasks > Generate SQL script. Specify a
filename and click OK.
This generates a script which you can modify and then run to create a
new job.
David Portas
SQL Server MVP

copy a job

Hi,
I need to copy a job to the same istance of Microsoft SQL 2000 (SP4). I'd
like to rename it modify some parameters and re-schedule the database.
I can't find nothing for copy or duplicate the job.. any help? by Enterprise
Manager and Transact-SQL?
Thank's
AndreaRight-click the job, select All Tasks > Generate SQL script. Specify a
filename and click OK.
This generates a script which you can modify and then run to create a
new job.
--
David Portas
SQL Server MVP
--

copy a file with xp_cmdshell

hi friends,
how to move a file from client to server through xp_cmdshell
please provide the script
thanks
reddy
What exactly is it that you have a problem with? Just use cp_cmdshell and execute the desired copy
command, where you specify the paths to the files using UNC naming, like:
EXEC master..xp_cmdshell 'COPY \\machine1\sharename\filename.txt \\machine2\sharename\filename.txt'
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"reddy" <reddy@.discussions.microsoft.com> wrote in message
news:7D3AFFFE-C388-4B3A-929A-211B5DD5A419@.microsoft.com...
> hi friends,
> how to move a file from client to server through xp_cmdshell
> please provide the script
> thanks
> reddy
|||hi tibor,
i used the same command.
the error is Logon failure: unknown user name or bad password.
please help
thanks
reddy
|||hi tibor,
i used the same command.
the error is Logon failure: unknown user name or bad password.
please help
thanks
reddy
|||If copying to/from a remote drive, check that your SQL Server service is
started using a domain user account, not the Local System account, and
ensure that the right permissions are granted to this domain user to access
that remote drive.
You can check this by running the dir command from within xp_cmdshell e.g.
xp_cmdshell 'dir \\network share name'
Peter Yeoh
http://www.yohz.com
Need smaller SQL2K backups? Try MiniSQLBackup
"reddy" <reddy@.discussions.microsoft.com> wrote in message
news:14F3F85F-691A-4CD4-BA21-352F2176104A@.microsoft.com...
> hi tibor,
> i used the same command.
> the error is Logon failure: unknown user name or bad password.
> please help
> thanks
> reddy
>
|||If copying to/from a remote drive, check that your SQL Server service is
started using a domain user account, not the Local System account, and
ensure that the right permissions are granted to this domain user to access
that remote drive.
You can check this by running the dir command from within xp_cmdshell e.g.
xp_cmdshell 'dir \\network share name'
Peter Yeoh
http://www.yohz.com
Need smaller SQL2K backups? Try MiniSQLBackup
"reddy" <reddy@.discussions.microsoft.com> wrote in message
news:14F3F85F-691A-4CD4-BA21-352F2176104A@.microsoft.com...
> hi tibor,
> i used the same command.
> the error is Logon failure: unknown user name or bad password.
> please help
> thanks
> reddy
>
|||hi friends,
i tried all your suggestions.but not working for me.
i am getting the follwing errors
if i use copy
EXEC master..xp_cmdshell 'xcopy \\e-060\c\updates.txt d\upd.txt'
Invalid drive specification
if i use xcopy
EXEC master..xp_cmdshell 'xcopy \\e-060\c\updates.txt d\upd.txt'
Logon failure: unknown user name or bad password.
plase suggest if any otherways are there to copy the files
thanks®ards
reddy
|||hi friends,
i tried all your suggestions.but not working for me.
i am getting the follwing errors
if i use copy
EXEC master..xp_cmdshell 'xcopy \\e-060\c\updates.txt d\upd.txt'
Invalid drive specification
if i use xcopy
EXEC master..xp_cmdshell 'xcopy \\e-060\c\updates.txt d\upd.txt'
Logon failure: unknown user name or bad password.
plase suggest if any otherways are there to copy the files
thanks®ards
reddy
|||Check your SQL Server service account (go to Administrative Tools /
Services). Is it started using the Local System account? If it is, use a
domain user account instead.
Peter Yeoh
http://www.yohz.com
Need smaller SQL2K backups? Try MiniSQLBackup
"reddy" <reddy@.discussions.microsoft.com> wrote in message
news:1F112BD9-1970-4144-B6B0-994881CF46C9@.microsoft.com...
> hi friends,
> i tried all your suggestions.but not working for me.
> i am getting the follwing errors
> if i use copy
> EXEC master..xp_cmdshell 'xcopy \\e-060\c\updates.txt d\upd.txt'
> Invalid drive specification
> if i use xcopy
> EXEC master..xp_cmdshell 'xcopy \\e-060\c\updates.txt d\upd.txt'
> Logon failure: unknown user name or bad password.
> plase suggest if any otherways are there to copy the files
> thanks®ards
> reddy
>
|||Check your SQL Server service account (go to Administrative Tools /
Services). Is it started using the Local System account? If it is, use a
domain user account instead.
Peter Yeoh
http://www.yohz.com
Need smaller SQL2K backups? Try MiniSQLBackup
"reddy" <reddy@.discussions.microsoft.com> wrote in message
news:1F112BD9-1970-4144-B6B0-994881CF46C9@.microsoft.com...
> hi friends,
> i tried all your suggestions.but not working for me.
> i am getting the follwing errors
> if i use copy
> EXEC master..xp_cmdshell 'xcopy \\e-060\c\updates.txt d\upd.txt'
> Invalid drive specification
> if i use xcopy
> EXEC master..xp_cmdshell 'xcopy \\e-060\c\updates.txt d\upd.txt'
> Logon failure: unknown user name or bad password.
> plase suggest if any otherways are there to copy the files
> thanks®ards
> reddy
>

copy a file with xp_cmdshell

hi friends,
how to move a file from client to server through xp_cmdshell
please provide the script
thanks
reddyWhat exactly is it that you have a problem with? Just use cp_cmdshell and ex
ecute the desired copy
command, where you specify the paths to the files using UNC naming, like:
EXEC master..xp_cmdshell 'COPY \\machine1\sharename\filename.txt \\machine2\
sharename\filename.txt'
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"reddy" <reddy@.discussions.microsoft.com> wrote in message
news:7D3AFFFE-C388-4B3A-929A-211B5DD5A419@.microsoft.com...
> hi friends,
> how to move a file from client to server through xp_cmdshell
> please provide the script
> thanks
> reddy|||hi tibor,
i used the same command.
the error is Logon failure: unknown user name or bad password.
please help
thanks
reddy|||If copying to/from a remote drive, check that your SQL Server service is
started using a domain user account, not the Local System account, and
ensure that the right permissions are granted to this domain user to access
that remote drive.
You can check this by running the dir command from within xp_cmdshell e.g.
xp_cmdshell 'dir \\network share name'
Peter Yeoh
http://www.yohz.com
Need smaller SQL2K backups? Try MiniSQLBackup
"reddy" <reddy@.discussions.microsoft.com> wrote in message
news:14F3F85F-691A-4CD4-BA21-352F2176104A@.microsoft.com...
> hi tibor,
> i used the same command.
> the error is Logon failure: unknown user name or bad password.
> please help
> thanks
> reddy
>|||hi friends,
i tried all your suggestions.but not working for me.
i am getting the follwing errors
if i use copy
EXEC master..xp_cmdshell 'xcopy \\e-060\c\updates.txt d\upd.txt'
Invalid drive specification
if i use xcopy
EXEC master..xp_cmdshell 'xcopy \\e-060\c\updates.txt d\upd.txt'
Logon failure: unknown user name or bad password.
plase suggest if any otherways are there to copy the files
thanks®ards
reddy|||Check your SQL Server service account (go to Administrative Tools /
Services). Is it started using the Local System account? If it is, use a
domain user account instead.
Peter Yeoh
http://www.yohz.com
Need smaller SQL2K backups? Try MiniSQLBackup
"reddy" <reddy@.discussions.microsoft.com> wrote in message
news:1F112BD9-1970-4144-B6B0-994881CF46C9@.microsoft.com...
> hi friends,
> i tried all your suggestions.but not working for me.
> i am getting the follwing errors
> if i use copy
> EXEC master..xp_cmdshell 'xcopy \\e-060\c\updates.txt d\upd.txt'
> Invalid drive specification
> if i use xcopy
> EXEC master..xp_cmdshell 'xcopy \\e-060\c\updates.txt d\upd.txt'
> Logon failure: unknown user name or bad password.
> plase suggest if any otherways are there to copy the files
> thanks®ards
> reddy
>|||If this is a cut-n-paste of the actual code then it looks like you are
missing a ":" colon after the d in d\upd.txt
Should that read d:\upd.txt ' If not then it is a relative path are you
really sure it is there? I assume it is missing the colon based on the
error you received "Invalid drive specification"
"reddy" <reddy@.discussions.microsoft.com> wrote in message
news:1F112BD9-1970-4144-B6B0-994881CF46C9@.microsoft.com...
> hi friends,
> i tried all your suggestions.but not working for me.
> i am getting the follwing errors
> if i use copy
> EXEC master..xp_cmdshell 'xcopy \\e-060\c\updates.txt d\upd.txt'
> Invalid drive specification
> if i use xcopy
> EXEC master..xp_cmdshell 'xcopy \\e-060\c\updates.txt d\upd.txt'
> Logon failure: unknown user name or bad password.
> plase suggest if any otherways are there to copy the files
> thanks®ards
> reddy
>

Copy a diagram from a db to another db in sql server 2005

Hello,
is there a way in SQL Server 2005 to copy a diagram from a database to
another one that has exactly the
same structure?
Thank you in advance,
Laura
You need to create the support tables for diagrams in the
destination database first - you can just click on the
database diagrams node in the destination database and
select Yes when the message box comes up asking if you want
to create the objects to use database diagramming.
Then import the dbo.sysdiagrams table from the source
database.
-Sue
On Tue, 31 Jul 2007 07:14:01 -0700, Isotta
<laura.lega@.gmail.com> wrote:

>Hello,
>is there a way in SQL Server 2005 to copy a diagram from a database to
>another one that has exactly the
>same structure?
>Thank you in advance,
>Laura

Copy a diagram from a db to another db in sql server 2005

Hello,
is there a way in SQL Server 2005 to copy a diagram from a database to
another one that has exactly the
same structure?
Thank you in advance,
LauraYou need to create the support tables for diagrams in the
destination database first - you can just click on the
database diagrams node in the destination database and
select Yes when the message box comes up asking if you want
to create the objects to use database diagramming.
Then import the dbo.sysdiagrams table from the source
database.
-Sue
On Tue, 31 Jul 2007 07:14:01 -0700, Isotta
<laura.lega@.gmail.com> wrote:

>Hello,
>is there a way in SQL Server 2005 to copy a diagram from a database to
>another one that has exactly the
>same structure?
>Thank you in advance,
>Laura

Copy a diagram from a db to another db in sql server 2005

Hello,
is there a way in SQL Server 2005 to copy a diagram from a database to
another one that has exactly the
same structure?
Thank you in advance,
LauraYou need to create the support tables for diagrams in the
destination database first - you can just click on the
database diagrams node in the destination database and
select Yes when the message box comes up asking if you want
to create the objects to use database diagramming.
Then import the dbo.sysdiagrams table from the source
database.
-Sue
On Tue, 31 Jul 2007 07:14:01 -0700, Isotta
<laura.lega@.gmail.com> wrote:
>Hello,
>is there a way in SQL Server 2005 to copy a diagram from a database to
>another one that has exactly the
>same structure?
>Thank you in advance,
>Laura

copy a db, identity problem

hi
i need to copy a db to another db every single table to another similar to
the first one but with some difference. When i try to do that i need to
remove some constraint and all the identity on the new db. i'd like do that
with a script, i tried:
CREATE TABLE (
id int IDENTITY (1,1) NOT NULL
)
ALTER TABLE prova ALTER COLUMN id int null
GO
it doesnt work.
how can i remove identity from a column of my table'
tx
carloYou can't directly remove the IDENTITY property. You would have to
create a new column or new version of the table.
However, you can use the SET IDENTITY_INSERT option to allow you to
populate the column without removing the IDENTITY property. See Books
Online for details.
David Portas
SQL Server MVP
--|||>> how can i remove identity from a column of my table'
You cannot do this directly. The alternative is to create another table,
copy the data & rename it. The EM interface can get this done with a few
mouse clicks and it may perform reasonably for small-medium sized tables.
Anith|||You don't need to. And, actually, you shouldn't. Look up SET IDENTITY_INSERT
in Books Online. And then use it.
It helps you achieve exactly what you need (judging from your post).
ML

Copy a database with copy the .mdf file and attaching it with a new name?

Hello,

if i have a given database (a model) and i want to copy this database in the same database instance. Is it ok to copy the mdf and ldf file and attach the files with a new database name in the same instance.

Or is the datebase name part of the .mdf file?

Regards
Markus

Hi,

I had no problems doing just that and the documentation only mentions to detach the database before taking the database file (or files) to copy them for later attaching. So I guess you should not just stop sql server and copy the files, but detach db, copy db files, reattach db.

--
SvenC

|||

hi Markus,

Markus Sch. wrote:

Hello,

if i have a given database (a model) and i want to copy this database in the same database instance. Is it ok to copy the mdf and ldf file and attach the files with a new database name in the same instance.

please be carefull not to overwrite existing database files... but the "scenario" is viable...

Or is the datebase name part of the .mdf file?

Regards
Markus

only User Instances use the Database Name ( and path) to dynamically build database names..

regards

|||

I tried this - and it did not really work. I could attach the copied database after renaming it and the original database, but then it would still point to the first physical database, i.e. the original .mdf-file ... Later the database wasn't recognized anymore ... etc.

There is a much easiere way that I finally figured out:

- right click on the database you want to copy

- select "Tasks" and subsequently select "Backup" and do a backup.

- right click on "Databases"

- select "Restore database"

- Enter the name of a new database (your copy target) and select the database to be copied as source database

- click "OK" (SQL Server creates a new database from the backup which means that you actually copied the original database)

If you only wanted the database design and not the content, well ... Delete from <tablename> ...

|||

hi,

rf wrote:

I tried this - and it did not really work. I could attach the copied database after renaming it and the original database, but then it would still point to the first physical database, i.e. the original .mdf-file ... Later the database wasn't recognized anymore ... etc.

I said, to be carefull ..

There is a much easiere way that I finally figured out:

- right click on the database you want to copy

- select "Tasks" and subsequently select "Backup" and do a backup.

- right click on "Databases"

- select "Restore database"

- Enter the name of a new database (your copy target) and select the database to be copied as source database

- click "OK" (SQL Server creates a new database from the backup which means that you actually copied the original database)

If you only wanted the database design and not the content, well ... Delete from <tablename> ...

yes, this works as well, but, again, you have to be carefull with the actual physical database file as well.. you have to "move" them according to your needs not overwriting existing database files...

regards

|||

rf571786 wrote:

I tried this - and it did not really work. I could attach the copied database after renaming it and the original database, but then it would still point to the first physical database, i.e. the original .mdf-file ... Later the database wasn't recognized anymore ... etc.

Hello rf,

if you detach a database with Management Studio Express, copy the .mdf and .ldf file, and then try to attach the copied files with Databases - Attach, then in the Attach Dialog the Attach As and Current File Path textboxes still have the old name.

The values are not changed to the new .mdf filename.

You have to type in the new database name in the Attach As textbox and the new file names in the Current File Path textbox. Then it works fine.

Or use a Sql Script. The InfoItems.mdf and Infotems_log.ldf files where copied to InfoItems_Test.mdf and Infotems_Test_Log.ldf and then attached with this Sql Script.

But the logical filename in Database Properties - Files - LogicalName still is InfoItems? It should be InfoItems_Test because the Name Clause was specified in the Sql statement?

Regards Markus


USE [master]
GO
CREATE DATABASE [InfoItems_Test] ON
(NAME = InfoItems_Test,
FILENAME = N'E:\InfoItems_Dev\Development\....\Data\DB\InfoItems_Test.mdf' ),
(NAME = InfoItems_Test_Log,
FILENAME = N'E:\InfoItems_Dev\Development\....\Data\DB\InfoItems_Test_log.ldf' )
FOR ATTACH
GO
if not exists (select name from master.sys.databases sd where name = N'InfoItems_Test'
and SUSER_SNAME(sd.owner_sid) = SUSER_SNAME() )
EXEC [InfoItems_Test].dbo.sp_changedbowner @.loginame=N'....\....', @.map=false
GO