Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Wie kann man mit MS SQL Server einen Funktionswert (z.B. die Differenz zweier Daten) in ein Feld einer Tabelle schreiben?

aber wie kann ich den Ausgabewert der Funktion in den Value-Befehl von Insert einbauen? Die Übergabe mittels Alias hat zumindest nicht funktioniert.

Ich möchte einen Funktionswert (die Differenz zweier Daten) in eine Tabelle schreiben.

Mit folgender Syntax war es nicht möglich:

SELECT p.checkin, p.checkout, h.GesTage

FROM personen AS p, hotel AS h

INSERT INTO hotel(GesTage) 

Value(datediff(day, checkin, checkout))

Erläuterung:

checkin = 1. Datum

checkout = 2. Datum

Kann mir jemand den Fehler zeigen?

Auch mittels Subselect lässt sich das Problem nicht beheben.

Die Schwierigkeit liegt im Endeffekt darin, dass ich den Rückgabewert der Funktion DATEDIFF nicht mittels Variable an VALUES () weitergeben kann:

z.B. mittels ALIAS

DATEDIFF(day, checkin, checkout) AS Datum

INSERT INTO Hotel(Tage)

VALUES(Datum)

Es ist auch nicht möglich, die Funktion direkt in VALUES zu schreiben:

VALUES(DATEDIFF(day, checkin, checkout))

Die Syntax lautet wie folgt:

insert into tabelle (col1,col2,col3) select (colxy-colabc),col10,col20 from andere_tabelle

Dim

Und an welcher Stelle muss ich jetzt meine Funktion eingeben?

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.