You may optionally enter a comparison operator (<, <=, >, >=, <> or =) at the beginning of each of your search values to specify how the comparison should be done.
Manuell einen AutoIncrement/Identity/Serial Wert in Tabelle einfügen
SET IDENTITY_INSERT myTable ON
INSERT INTO myTable(Identity_ID, Value) VALUES (4711, 'Back To The Future...')
SET IDENTITY_INSERT myTable OFF
208
PL/pgSQL
Datenbank
Tabelleinhalt DB übergreifend kopieren
-- siehe auch: http://stackoverflow.com/questions/6083132/postgresql-insert-into-select
-- in DestinationDB do:
INSERT INTO Table1
SELECT id, valuefield
FROM dblink('dbname=SourceDB', 'SELECT id, valuefield FROM Table1')
AS t(id integer, valuefield varchar(100));
213
T-SQL
Datenbank
DB-Funktion erstellen
-- Table-value
-- Variant 1
CREATE FUNCTION whichContinent
(@country nvarchar(15))
RETURNS TABLE
AS
RETURN
(
SELECT @country AS Country
)
-- Variant 2
CREATE FUNCTION whichContinent
(@country nvarchar(15))
RETURNS
@returnTableResult TABLE
(
id int
,currency VARCHAR(100)
)
AS
BEGIN
IF @country='Germany'
BEGIN
INSERT INTO @returnTableResult VALUES (1,'EURO')
END
RETURN
END
222
MySQL
Datenbank
NULL Wert eines Feldes übersteuern
SELECT IFNULL(MyColumn1, 1) AS MyColumnWithoutNULL;
235
MySQL
Datenbank
Aktuellen Datenbanknamen ausgeben
SELECT DATABASE() AS DB_Name;
244
T-SQL
Datenbank
SQL SELECT Statische Werte
SELECT
*
FROM (
VALUES
(1, 2),
(3, 4)
) AS q (col1, col2)
GO
-- the same as:
SELECT 1 AS col1, 2 AS col2 UNION ALL
SELECT 3 AS col1, 4 AS col2
GO
-- col1 | col2
-- ===========
-- 1 | 2
-- -----------
-- 3 | 4
245
PL/pgSQL
Datenbank
SQL SELECT Statische Werte
SELECT
*
FROM (
VALUES
(1, 2),
(3, 4)
) AS q (col1, col2)
;
-- the same as:
SELECT 1 AS col1, 2 AS col2 UNION ALL
SELECT 3 AS col1, 4 AS col2
;
-- col1 | col2
-- ===========
-- 1 | 2
-- -----------
-- 3 | 4
247
ORACLE PL/SQL
Datenbank
CSV erstellen
SELECT FieldA, LISTAGG(CSVItem, ',') WITHIN GROUP (ORDER BY FieldA) AS Members
FROM TableWithItems
GROUP BY FieldA;
266
MS Access VBA
Array
Dictionary Basics
' empty dict
Dim myDict As Dictionary
Set myDict = New Dictionary
' some static values
myDict.Add "key1", "value1"
myDict.Add "key2", "valueY"
myDict.Add "keyX", "value98"
' update a key programmatically
myDict.Remove "key1"
myDict.Add "key1", "new value"
' iterate
Dim strKey As Variant
Dim current_key As String
Dim strValue As String
For Each strKey In myDict.Keys()
current_key = strKey
strValue = myDict.Keys(strKey)
Next
' Exists
If myDict.Exists(strKey) Then
Debug.Print "yes"
End If
' get an specific item
Dim subdict As String
subdict = myDict.Keys("key2")
# valueY
267
PowerShell
Array
Dictionary Basics
# empty Hashtable
$myDict = @{}
# some static values
$myDict.Add("key1", "value1")
$myDict.Add("key2", "valueY")
$myDict.Add("keyX", "value98")
# update a key programmatically
$myDict.Remove("key1")
$myDict.Add("key1", "new value")
# iterate
Foreach ($key in $myDict.keys) {
$strKey = $key
$strValue = $Parameter[$key]
}
# Exists
If ($myDict.ContainsKey("key1") -eq $true) {
write-host "yes"
}
# get an specific item
$subdict = $myDict("key2")
# valueY