How I make sql queries for coping one table (exist) to another table
(no exist)One method:
INSERT INTO AnotherTable
SELECT *
FROM OneTable
WHERE NOT EXISTS
(
SELECT *
FROM AnotherTable
WHERE AnotherTable.PK = OneTable.PK
)
Hope this helps.
Dan Guzman
SQL Server MVP
<f1414@.mail.ru> wrote in message
news:pje101lo8a0j5lkltd5ftuhd90ja7rmft9@.
4ax.com...
> How I make sql queries for coping one table (exist) to another table
> (no exist)|||SELECT * INTO NewTable FROM OldTable WHERE 1=1 (with data) OR WHERE 1=2
(without)
Note, that it does not transfer neither a PK,FK,indexes,Constraints
<f1414@.mail.ru> wrote in message
news:pje101lo8a0j5lkltd5ftuhd90ja7rmft9@.
4ax.com...
> How I make sql queries for coping one table (exist) to another table
> (no exist)|||SELECT *
INTO NewTable
FROM ExistingTable
Roji. P. Thomas
Net Asset Management
https://www.netassetmanagement.com
<f1414@.mail.ru> wrote in message
news:pje101lo8a0j5lkltd5ftuhd90ja7rmft9@.
4ax.com...
> How I make sql queries for coping one table (exist) to another table
> (no exist)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment