cheap nfl jerseys china cheap nfl jerseys free shipping wholesale nfl jerseys china wholesale jerseys from china cheap nfl jerseys free shipping cheap nfl jerseys for sale cheap jerseys free shipping wholesale nfl jerseys from china cheap nfl jerseys sale cheap nike nfl jerseys china wholesale jerseys free shipping cheap nfl jerseys wholesale wholesale nfl jerseys online cheap nfl jerseys wholesale china jerseys wholesale cheap coach handbags outlet authentic designer handbags cheap coach handbags outlet cheap coach purses outlet discount coach bags coach bags sale coach purse outlet cheap real coach purses coach handbags sale online coach purse outlet michael kors outlet online store cheap michael kors bags cheap michael kors purse michael kors factory outlet online cheap michael kors handbags cheap michael kors purses michael kors bags outlet online cheap michael kors purse michael kors handbags discount cheap michael kors purse michael kors handbags discount
cheap nfl jerseys china cheap nfl jerseys free shipping wholesale nfl jerseys china wholesale jerseys from china cheap nfl jerseys free shipping cheap nfl jerseys for sale cheap jerseys free shipping wholesale nfl jerseys from china cheap nfl jerseys sale cheap nike nfl jerseys china wholesale jerseys free shipping cheap nfl jerseys wholesale wholesale nfl jerseys online cheap nfl jerseys wholesale china jerseys wholesale cheap coach handbags outlet authentic designer handbags cheap coach handbags outlet cheap coach purses outlet discount coach bags coach bags sale coach purse outlet cheap real coach purses coach handbags sale online coach purse outlet michael kors outlet online store cheap michael kors bags cheap michael kors purse michael kors factory outlet online cheap michael kors handbags cheap michael kors purses michael kors bags outlet online cheap michael kors purse michael kors handbags discount cheap michael kors purse michael kors handbags discount
funzioni


funzioni di sistema

  • le funzioni accoppiate:
    DB_ID('database_name')DB_NAME(database_id)
    HOST_ID( )HOST_NAME( )
    OBJECT_ID('object_name')OBJECT_NAME(object_id)
    SUSER_ID('server_username')SUSER_NAME(server_user_id)
    USER_ID('username')USER_NAME(user_id)
    • SUSER_ID(sa) = 1
    • SUSER_ID(guest) = -1
    • USER_ID(db_owner) = 1
  • sul database:
    • GETANSINULL(['database_name']): la nullability default del database
  • sulle tabelle:
    • COL_NAME(table_id,column_id)
    • COL_LENGTH('table_name','column_name')
    • INDEX_COL('table_name',index_id,key_id): nome della colonna indicizzata
    • STATS_DATE(table_id,index_id): data di aggiornamento dell'indice
    • IDENT_INCR('table_name'): incremento di una colonna identit�
    • IDENT_SEED('table_name'): seed di una colonna identit�
  • sui valori:
    • COALESCE(espr1,espr2,...,esprn): la prima espressione non nulla
    • DATALENGTH('espressione'): lunghezza
    • ISNULL(espressione,valore): sostituisce i valori NULL
    • NULLIF(espr1,espr2): NULL se espr1=espr2


funzioni di aggregazione

calcolano valori riassuntivi di una colonna o di una espressione

MIN | MAX | SUM | AVG | COUNT (espressione)

  • se usate sole restituiscono un solo valore
  • se usate con GROUP BY restituiscono una colonna con un valore per ogni aggregazione di righe
  • se usate con COMPUTE BY restituiscono righe supplementari
con GROUP BY si pu� aggiungere la clausola [ALL|DISTINCT] e inoltre c'� COUNT(*), che conta tutte le righe, anche quelle con valori nulli


funzioni matematiche

  • EXP, POWER, SQRT, LOG, LOG10
  • SIGN, ABS, CEILING, FLOOR, ROUND
  • ASIN, ACOS, ATAN, ATN2, COS, COT, SIN, TAN
  • DEGREES, RADIANS
  • RAND
  • PI


funzioni data

  • GETDATE()
  • DATEPART(parte,data)
  • DATENAME(parte,data)
  • DATEDIFF(parte,data1,data2)
  • DATEADD(parte,data1,data2)

  • parti di una data:
    yy (year: 1753-9999), qq (quarter: 1-4), mm (month: 1-12), dy (day of year: 1-366), dd (day: 1-31), wk (week: 1-53), dw (weekday: 1-7 o Sun-Sat), hh (hour: 0-23), mi (minute: 0-59), ss (second: 0-59), ms (millisecond: 0-999)


funzioni stringa

  • +: concatenazione
  • ASCII, CHAR: conversioni
  • SUBSTRING(espressione,inizio,lunghezza): sottostringa
  • RIGHT(espressione,intero)
  • CHARINDEX('modello',espressione): localizza una sottostringa
  • PATINDEX('modello',espressione): accetta wildcard characters
  • STUFF(stringa1,inizio,lunghezza,stringa2): sostituisce una sottostringa
  • REPLICATE(espressione,intero)
  • SPACE(intero)
  • LTRIM, RTRIM: tolgono i bianchi
  • LOWER, UPPER: cambiano il case
  • REVERSE
  • SOUNDEX(stringa): genera un codice
  • DIFFERENCE(stringa1, stringa2): confronta il SOUNDEX

  • STR(numero[,lunghezza,decimali]): da numero a stringa


funzioni testo e immagini

  • IS [NOT] NULL
  • LIKE

  • PATINDEX('modello',espressione) accetta wildcard characters
  • DATALENGTH(espressione)

  • per UPDATETEXT, WRITETEXT, READTEXT:
    • TEXTPTR(nome_colonna): text-pointer, per assicurarsi che punti all'inizio
    • TEXTVALID('nome_tabella.nome_colonna',text_ptr): validit� di un text-pointer


funzione CONVERT

  • CONVERT(tipo[(lunghezza)],espressione[,stile])

  • CONVERT(char(10),nome): parte iniziale della stringa
  • CONVERT(int,stringa): stringa -> intero

  • lo stile si applica alle date:
    CONVERT(char(12),data,103): data -> stringa
    • stile 3: dd/mm/yy (8 caratteri)
    • stile 103: dd/mm/yyyy (10 caratteri)
    • stile 113: dd mon yyyy hh:mm (17 caratteri)

  • per i numeri reali, meglio usare STR( )