SEARCH_IP

functionsupportedCore SQL functions

docs.snowflake.com ↗

String & binary functions

Searches for valid IPv4 and IPv6 addresses in specified character-string columns from one or more tables, including fields in VARIANT, OBJECT, and ARRAY columns. The search is based on a single IP address or a range of IP addresses that you specify. If an IP address in the column or field matches a specified IP address or is in a specified range, then the function returns TRUE. For more information about using this function, see Using full-text search.

Syntax

SEARCH_IP( <search_data>, '<search_string>' )

Parameters

NameRequiredDescription
search_datarequiredThe data you want to search, expressed as a comma-delimited list of string literals, column names, or paths to fields in VARIANT columns. The search data can also be a single literal string, which can be useful when you are testing the function. You can specify the wildcard character (*), where * expands to all qualifying columns in all of the tables that are in scope for the function. Qualifying columns are those that have VARCHAR (text), VARIANT, ARRAY, and OBJECT data types. VARIANT, ARRAY, and OBJECT data is converted to text for searching. You can also use the ILIKE and EXCLUDE keywords for filtering. For more information about this argument, see the search_data description for the SEARCH function.
'search_string'requiredA VARCHAR string that contains one of the following addresses: A complete and valid IP address in standard IPv4 or IPv6 format, such as 192.0.2.1 or 2001:0db8:85a3:0000:0000:8a2e:0370:7334. A valid IP address in standard IPv4 or IPv6 format with a Classless Inter-Domain Routing (CIDR) range, such as 192.0.2.1/24 or 2001:db8:85a3::/64. A valid IP address in standard IPv4 or IPv6 format with leading zeros, such as 192.000.002.001 instead of 192.0.2.1 or 2001:0db8:85a3:0333:4444:8a2e:0370:7334 instead of 2001:db8:85a3:333:4444:8a2e:370:7334. The function accepts up to three digits for each part of an IPv4 address, and up to four digits for each part of an IPv6 address. A valid compressed IPv6 address, such as 2001:db8:85a3:0:0:0:0:0 or 2001:db8:85a3:: instead of 2001:db8:85a3:0000:0000:0000:0000:0000. An IPv6 dual address that combines an IPv6 and an IPv4 address, such as 2001:db8:85a3::192.0.2.1. This argument must be a literal string. Specify one pair of single quotes around the string. The following types of arguments aren’t supported: Column names Empty strings More than one IP address Partial IPv4 and IPv6 addresses

Returns

Returns a BOOLEAN: - Returns TRUE if a valid IP address is specified in search_string and a matching IP address is found in search_data. - Returns TRUE if a valid IP address with a CIDR range is specified in search_string and an IP address in the specified range is found in search_data. - Returns NULL if either of these arguments is NULL. - Otherwise, returns FALSE.

Usage notes