Check nr of fractional digits

PHOTO EMBED

Thu Jul 01 2021 13:46:30 GMT+0000 (Coordinated Universal Time)

Saved by @Bartcw89 #sql

<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets>
	<CodeSnippet>
		<Header>
			<Title>Check nr of fractional digits</Title>
		</Header>
		<Snippet>
			<Declarations>
				<Literal>
					<ID>Exponent</ID>
					<ToolTip>Exponentiation</ToolTip>
					<Default>2</Default>
				</Literal>
				<Literal>
					<ID>ColumnName</ID>
					<ToolTip>Name of the column</ToolTip>
					<Default>ColumnName</Default>
				</Literal>
				<Literal>
					<ID>TableName</ID>
					<ToolTip>Name of the table</ToolTip>
					<Default>TableName</Default>
				</Literal>
			</Declarations>
			<Code Language="SQL">
<![CDATA[DECLARE @power DECIMAL = POWER(10, $Exponent$);
SELECT Value
FROM (SELECT $ColumnName$ AS Value FROM dbo.$TableName$) AS Focus
WHERE ROUND(Value * @power, 0, 1) <> (Value * @power);]]>
			</Code>
		</Snippet>
	</CodeSnippet>
</CodeSnippets>
content_copyCOPY

Searches decimal values with a specific amount of fractional digits.