AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

set identity_insert

Ein Thema von Sandra · begonnen am 11. Dez 2003 · letzter Beitrag vom 12. Dez 2003
Antwort Antwort
Sandra

Registriert seit: 11. Dez 2003
1 Beiträge
 
#1

set identity_insert

  Alt 11. Dez 2003, 17:53
[sql]

Hallo Leute,


Ich habe mehrere bestehende Tabellen in einer MYSQL-DB, welche ich in eine SQL-DB transferiert werden sollen.
Mein Problem ist, dass ich einmal die Daten aus MYSQL mit insert in die neuen Tabellen einfügen möchte und wenn neue kommen diese mit identity(1,1) hochgezählt werden sollen. Um das zu realisieren habe ich einen SET-Befehl eingefügt (SET IDENTITY_INSERT tabellenname ON). Für eine Tabelle funktioniert dies auch alles.
Jetzt habe ich aber an die 20 Tabellen und bekomme die Meldung, das ich diesen Set-Befehl nur auf eine Tabelle anwenden kann.
Wie bekomme ich es hin, das bei den anderen Tabellen sowohl die Daten aus Mysql eingefügt werden und gleichzeitig bei neuen Daten diese hochgezählt werden?


Wäre super,wenn mir jemand weiter helfen könnte.

Sandra
  Mit Zitat antworten Zitat
Benutzerbild von SirThornberry
SirThornberry
(Moderator)

Registriert seit: 23. Sep 2003
Ort: Bockwen
12.235 Beiträge
 
Delphi 2006 Professional
 
#2

Re: set identity_insert

  Alt 11. Dez 2003, 18:46
Wenn ich dich recht verstanden hab exportierst du die datensätze ja erst. Da gäbe es die Möglichkeit einfach ein Delphiprogramm drüber zu jagen was doppelte zeilen sucht... Wozu dient das ganze (als das mitzählen)? Vielleicht gibt es ja für das problem noch eine ganz andere Lösung
Jens
Mit Source ist es wie mit Kunst - Hauptsache der Künstler versteht's
  Mit Zitat antworten Zitat
Benutzerbild von Marcel Gascoyne
Marcel Gascoyne

Registriert seit: 18. Nov 2003
Ort: Uetersen
271 Beiträge
 
Delphi 2005 Architect
 
#3

Re: set identity_insert

  Alt 12. Dez 2003, 06:17
Du kannst SET IDENTITY_INSERT immer nur auf eine Tabelle zur Zeit anwenden. Steht auch so in der Doku:

Zitat:
SET IDENTITY_INSERT
Allows explicit values to be inserted into the identity column of a table.

Syntax
SET IDENTITY_INSERT [ database. [ owner. ] ] { table } { ON | OFF }

Arguments
database

Is the name of the database in which the specified table resides.

owner

Is the name of the table owner.

table

Is the name of a table with an identity column.

Remarks
At any time, only one table in a session can have the IDENTITY_INSERT property set to ON. If a table already has this property set to ON, and a SET IDENTITY_INSERT ON statement is issued for another table, Microsoft® SQL Server™ returns an error message that states SET IDENTITY_INSERT is already ON and reports the table it is set ON for.

If the value inserted is larger than the current identity value for the table, SQL Server automatically uses the new inserted value as the current identity value.

The setting of SET IDENTITY_INSERT is set at execute or run time and not at parse time.
Ich würde mal versuchen die Daten zuerst in eine temporäre Tabelle zu importieren und dort die Werte, z.b. über eine Stored Procedure, zu Ändern. Danach schreibst Du alles in die echten Tabellen rein.

Gruß,
Marcel
Marcel Gascoyne
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 07:26 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz