\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{pxlcore} \pdfinfo{ /Title (sybase.pdf) /Creator (Cheatography) /Author (pxlcore) /Subject (Sybase Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{0B00A3} \definecolor{LightBackground}{HTML}{F7F7FC} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Sybase Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{pxlcore} via \textcolor{DarkBackground}{\uline{cheatography.com/39527/cs/12274/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}pxlcore \\ \uline{cheatography.com/pxlcore} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 4th October, 2017.\\ Updated 3rd January, 2019.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{3} \begin{tabularx}{5.377cm}{x{1.24425 cm} x{3.73275 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Sybase Data Types}} \tn % Row 0 \SetRowColor{LightBackground} TINYINT & Integer (0 to 255) \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} SMALLINT & Integer (-32768 to +32767) \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} INT & Integer (-2147483648 to +2147483647) \tn % Row Count 4 (+ 2) % Row 3 \SetRowColor{white} BIGINT & Integer (-9233372036854775808 to +9233372036854775807) \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} DECIMAL & Decimal (-10\textasciicircum{}38\textasciicircum{} and 10\textasciicircum{}38\textasciicircum{} -1) \tn % Row Count 8 (+ 2) % Row 5 \SetRowColor{white} NUMERIC & Decimal (-10\textasciicircum{}38\textasciicircum{} and 10\textasciicircum{}38\textasciicircum{} -1) \tn % Row Count 10 (+ 2) % Row 6 \SetRowColor{LightBackground} FLOAT & Decimal (8 byte, machine-dependent) \tn % Row Count 12 (+ 2) % Row 7 \SetRowColor{white} REAL & Decimal (4 byte, machine-dependent) \tn % Row Count 14 (+ 2) % Row 8 \SetRowColor{LightBackground} CHAR(n) & String (1 to 255) \tn % Row Count 15 (+ 1) % Row 9 \SetRowColor{white} NCHAR(n) & String (1 to 255) \tn % Row Count 16 (+ 1) % Row 10 \SetRowColor{LightBackground} \seqsplit{VARCHAR(n)} & String (1 to 255) \tn % Row Count 17 (+ 1) % Row 11 \SetRowColor{white} \seqsplit{NVARCHAR(n)} & String (1 to 255) \tn % Row Count 19 (+ 2) % Row 12 \SetRowColor{LightBackground} TEXT & String (2\textasciicircum{}31 characters) \tn % Row Count 20 (+ 1) % Row 13 \SetRowColor{white} MONEY & Decimal (922337203685477.5807 to -922337203685477.5808) \tn % Row Count 22 (+ 2) % Row 14 \SetRowColor{LightBackground} \seqsplit{SMALLMONEY} & Decimal (214748.3647 to -214748.3648) \tn % Row Count 24 (+ 2) % Row 15 \SetRowColor{white} DATE & Date (1753-01-01 to 9999-12-31) \tn % Row Count 26 (+ 2) % Row 16 \SetRowColor{LightBackground} DATETIME & DateTime (1753-01-01 to 9999-12-31) \tn % Row Count 28 (+ 2) % Row 17 \SetRowColor{white} \seqsplit{SMALLDATETIME} & DateTime (1900-01-01 to 2079-06-06) \tn % Row Count 30 (+ 2) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{1.24425 cm} x{3.73275 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Sybase Data Types (cont)}} \tn % Row 18 \SetRowColor{LightBackground} TIME & Time (12:00:00AM to 11:59:59:999PM) \tn % Row Count 2 (+ 2) % Row 19 \SetRowColor{white} TIMESTAMP & Timestamp \tn % Row Count 3 (+ 1) % Row 20 \SetRowColor{LightBackground} BIGTIME & Time (12:00:00.000000 AM to 11:59:59.999999 PM) \tn % Row Count 5 (+ 2) % Row 21 \SetRowColor{white} \seqsplit{BIGDATETIME} & DateTime (0001-01-01 to 9999-12-31 and 12:00.000000AM to 11:59:59.999999 PM) \tn % Row Count 8 (+ 3) % Row 22 \SetRowColor{LightBackground} BIT & Boolean (0 or 1) \tn % Row Count 9 (+ 1) % Row 23 \SetRowColor{white} BINARY & Binary (0 - 256 bytes) \tn % Row Count 10 (+ 1) % Row 24 \SetRowColor{LightBackground} VARBINARY & Binary (0 - 255 bytes) \tn % Row Count 11 (+ 1) % Row 25 \SetRowColor{white} IMAGE & Blob (Binary 2\textasciicircum{}31\textasciicircum{}) \tn % Row Count 12 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{CASE Statement}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{CASE value-expression \newline WHEN {[}constant | NULL{]} THEN statement-list … \newline {[} WHEN {[}constant | NULL{]} THEN statement-list {]} … \newline ELSE statement-list \newline END} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{IF Statement}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{IF condition THEN expression \newline {[}ELSE expression{]} \newline END {[}IF{]}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Local variables}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{DECLARE @c1 FLOAT, @c2 FLOAT \newline SELECT @c1 = 1000/1000 \newline SELECT @c2 = @c1/30 \newline SELECT @c1 , @c} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{LIST function {[}Aggregate{]}}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{LIST ( \newline {[}ALL | DISTINCT{]} string-expr \newline {[}, 'delimiter-string'{]} \newline {[}ORDER BY order-by-expr {[} ASC | DESC {]}, ... {]} \newline )} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\emph{Example:}} \newline `SELECT LIST(EmployeeID) FROM Employees GROUP BY DepartmentID`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{sa\_split\_list system procedure}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Takes a string of values, separated by a delimiter, and returns a set of rows—one row for each value. \newline % Row Count 3 (+ 3) `sa\_split\_list( str {[}, delim {]} {[}, maxlen {]})` \newline % Row Count 4 (+ 1) {\emph{Result set:}} \newline % Row Count 5 (+ 1) `line\_num` Sequential number for the row. \newline % Row Count 6 (+ 1) `row\_value` Value from the string, truncated to `maxlen` if required.% Row Count 8 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Local Temporary Table}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{DROP TABLE IF EXISTS table-name \newline DECLARE LOCAL TEMPORARY TABLE table-name \newline … ( col-name {[} col-constraint {]} … \newline {[} , col-name {[} col-constraint {]} … {]} \newline {[} , table-constraint {]} … ) \newline …{[} ON COMMIT \{ DELETE | PRESERVE \} ROWS NOT TRANSACTIONAL{]}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Push data to temp table \newline `INSERT INTO table-name SELECT ...` or \newline `SELECT * INTO table-name FROM ...`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{0.9154 cm} p{0.59501 cm} x{3.06659 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{5.377cm}}{\bf\textcolor{white}{DatePart abbrevations}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{datepart}} & {\bf{abbr}} & {\bf{values}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} year & yy & 1753–9999 (datetime) 1753–2079 (smalldatetime) 0001–9999 (bigdatetime) \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} quarter & qq & 1-4 \tn % Row Count 6 (+ 1) % Row 3 \SetRowColor{white} month & mm & 1-12 \tn % Row Count 7 (+ 1) % Row 4 \SetRowColor{LightBackground} week & wk & 1-54 \tn % Row Count 8 (+ 1) % Row 5 \SetRowColor{white} day & dd & 1-31 \tn % Row Count 9 (+ 1) % Row 6 \SetRowColor{LightBackground} \seqsplit{dayofyear} & dy & 1-366 \tn % Row Count 11 (+ 2) % Row 7 \SetRowColor{white} weekday & dw & 1–7 (Sun. – Sat.) \tn % Row Count 12 (+ 1) % Row 8 \SetRowColor{LightBackground} hour & hh & 0-23 \tn % Row Count 13 (+ 1) % Row 9 \SetRowColor{white} minute & mi & 0-59 \tn % Row Count 14 (+ 1) % Row 10 \SetRowColor{LightBackground} second & ss & 0-59 \tn % Row Count 15 (+ 1) % Row 11 \SetRowColor{white} \seqsplit{millisecond} & ms & 0-999 \tn % Row Count 17 (+ 2) % Row 12 \SetRowColor{LightBackground} \seqsplit{microseconds} & us & 0-999999 \tn % Row Count 19 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{DateAdd}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{DATEADD(date-part, value, timestamp)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\emph{Example:}} add 102 months to the date \newline `SELECT DATEADD(month, 102, '1987/05/02')`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{DateDiff}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{DATEDIFF(datepart, \{date, date | time, time | bigtime, bigtime | datetime, datetime | bigdatetime, bigdatetime\}{]})} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\emph{Example:}} hours between two dates \newline `SELECT DATEDIFF(hh, "apr 1, 1999", "apr 2, 1999")`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{REGEXP search condition}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{SELECT * FROM table-name \newline WHERE col-name REGEXP 'reg-expr';} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\emph{Example:}} \newline `SELECT Surname, Surname, City, Phone FROM Contacts WHERE Phone REGEXP '\textbackslash{}\textbackslash{}d\{8\}00';`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{REGEXP\_SUBSTR function}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{SELECT REGEXP\_SUBSTR( col-name, 'reg-expr' ) \newline FROM table-name;} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{{\emph{Example:}} \newline `SELECT REGEXP\_SUBSTR( Street, '(?\textless{}=\textasciicircum{}\textbackslash{}\textbackslash{}S+\textbackslash{}\textbackslash{}s+).*\$' ) FROM Customers;`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}