michelc Blog

Just <strong>another</strong> WordPress.com weblog

Archives de octobre 2005

Convertir un type String en Enum

sans commentaires

enum EngineType {
	unknow,
	access,
	db2,
	mysql,
	odbc,
	oledb,
	oracle,
	postgre,
	sqlserver
}
string cnxTypeString = "mysql";
EngineType cnxTypeEngine = EngineType.unknow;
if (Enum.IsDefined(typeof(EngineType), cnxTypeString)) {
	cnxTypeEngine = (EngineType) Enum.Parse(typeof(EngineType), cnxTypeString, true);
}

(Publié à l’origine sur http://www.bigbold.com/snippets/posts/show/824)

Rédigé par michel

20 octobre 2005 à 1:15

Publié dans Code Snippets, c#

Structure d’une table PostgreSQL depuis Information_Schema

sans commentaires

SELECT COLUMN_NAME,
       DATA_TYPE,
       CHARACTER_MAXIMUM_LENGTH,
       NUMERIC_PRECISION,
       NUMERIC_SCALE,
       IS_NULLABLE,
       SUBSTR(COALESCE(COLUMN_DEFAULT, '' ), 1, 8 ) = 'nextval(' AS IS_AUTOINCREMENT,
       COLUMN_DEFAULT
FROM   INFORMATION_SCHEMA.COLUMNS
WHERE  TABLE_NAME = 'xxxxxxxx'
ORDER BY ORDINAL_POSITION

(Publié à l’origine sur http://www.bigbold.com/snippets/posts/show/816)

Rédigé par michel

18 octobre 2005 à 1:50

Publié dans Code Snippets, sql

sans commentaires

SELECT COLUMN_NAME,
       DATA_TYPE,
       CHARACTER_MAXIMUM_LENGTH,
       NUMERIC_PRECISION,
       NUMERIC_SCALE,
       IS_NULLABLE,
       COLUMNPROPERTY(OBJECT_ID(TABLE_NAME), COLUMN_NAME, 'IsIdentity') AS IS_AUTOINCREMENT,
       COLUMN_DEFAULT
FROM   INFORMATION_SCHEMA.COLUMNS
WHERE  TABLE_NAME = 'xxxxxxxx'
ORDER BY ORDINAL_POSITION

(Publié à l’origine sur http://www.bigbold.com/snippets/posts/show/815)

Edit : Voir aussi “system_function_schema.fn_datadictionary“, une fonction qui renvoie le dictionnaire de données pour n’importe quelle base Sql Server.

Rédigé par michel

18 octobre 2005 à 1:45

Publié dans Code Snippets, sql