Presentation is loading. Please wait.

Presentation is loading. Please wait.

Business Solutions. Formatting It is sometimes necessary to alter the output of a query for the sake of readability such as in report generation. This.

Similar presentations


Presentation on theme: "Business Solutions. Formatting It is sometimes necessary to alter the output of a query for the sake of readability such as in report generation. This."— Presentation transcript:

1 Business Solutions

2 Formatting It is sometimes necessary to alter the output of a query for the sake of readability such as in report generation. This can also be applied to a view creation which users will share.

3 SUBSTRING Returns a part of a character or binary string. SUBSTRING (expression, start, length) SUBSTRING (expression, start, length) SUBSTRING (‘SQL Programming’, 1, 3) = SQL SUBSTRING (‘SQL Programming’, 1, 3) = SQL

4 CONVERT Changes one datatype to another. CONVERT(datatype[length], expression) CONVERT(char(2), ‘SQL’) = SQ CONVERT(int, ‘10’) = 10

5 Using them together... Select substring(title_id, 1, 2) as alpha convert(int, substring(title_id, 3, 4)) as num from titles

6 Other data Col_length - returns the length defined for a specific column. COL_LENGTH(‘table_name’, ‘col_name’) Data_length - returns the length of the data in an expression DATA_LENGTH(expression)

7 REPLICATE Replicates a given character or string the number of times specified. REPLICATE(char, int)

8 ROUND Rounds a number according to the specified accuracy. ROUND (col, int)

9 CHARINDEX Returns the index position of the specified string. CHARINDEX(search_str, str) CHARINDEX(‘.’, ‘12.3’) = 3

10 LIKE Ranges LIKE ‘[A-Z] [a-z] [a-z]’ Wildcards LIKE ‘_ _ _ _’ LIKE ‘[^] [^] [^]’ LIKE ‘%SQL%’


Download ppt "Business Solutions. Formatting It is sometimes necessary to alter the output of a query for the sake of readability such as in report generation. This."

Similar presentations


Ads by Google