and(50), rand();
select round(rand(), 3), round(rand(100), 5);
select round(123.456, 2), round(254.124, -2);
select round(123.4567, 1, 2);
– 元数据
select col_name(object_id(‘student’), 1); // 返回列名
select col_name(object_id(‘student’), 2);
– 该列数据类型长度
select col_length(‘student’, col_name(object_id(‘student’), 2));
– 该列数据类型长度
select col_length(‘student’, col_name(object_id(‘student’), 1));
– 返回类型名称、类型id
select type_name(type_id(‘varchar’)), type_id(‘varchar’);
– 返回列类型长度
select columnProperty(object_id(‘student’), ‘name’, ‘PRECISION’);
– 返回列所在索引位置
select columnProperty(object_id(‘student’), ‘sex’, ‘ColumnId’);
– 字符串函数
select ascii('a');
select ascii('A');
select char(97);
select char(65);
select nchar(65);
select nchar(45231);
select nchar(32993);
select unicode('A'), unicode('中');
select soundex('hello'), soundex('world'), soundex('word');
select patindex('%a', 'ta'), patindex('%ac%', 'jack'), patindex('dex%', 'dexjack');
select 'a' + space(2) + 'b', 'c' + space(5) + 'd';
select charIndex('o', 'hello world');
select charIndex('o', 'hello world', 6);
select quoteName('abc[]def'), quoteName('123]45');
select str(123.456, 2), str(123.456, 3), str(123.456, 4);
select str(123.456, 9, 2), str(123.456, 9, 3), str(123.456, 6, 1), str(123.456, 9, 6);
select difference('hello', 'helloWorld');
select difference('hello', 'world');
select difference('hello', 'llo');
select difference('hello', 'hel');
select difference('hello', 'hello');
select replace('abcedef', 'e', 'E');
select stuff('hello world', 3, 4, 'ABC');
select replicate('abc#', 3);
select subString('abc', 1, 1), subString('abc', 1, 2), subString('hello Wrold', 7, 5);
select len('abc');
select reverse('sqlServer');
select left('leftString', 4);
select left('leftString', 7);
select right('leftString', 6);
select right('leftString', 3);
select lower('aBc'), lower('ABC');
select upper('aBc'), upper('abc');
select ltrim(' abc'), ltrim('# abc#'), ltrim(' abc');
select rtrim(' abc '), rtrim('# abc# '), rtrim('abc');