带有二进制的 SQL WHERE 子句

编程入门 行业动态 更新时间:2024-10-25 07:17:23
本文介绍了带有二进制的 SQL WHERE 子句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个带有 varbinary(max) 列的 SQL Server 数据库表(即 create table 命令中的 Data VarBinary(max)).

I have a SQL Server database table with a varbinary(max) column (i.e. Data VarBinary(max) in a create table command).

是否可以在二进制数据中使用某种模式匹配来执行 where 子句?

Is it possible to do a where clause with some kind of pattern matching within the binary data?

例如,使用C#.NET的SqlCommand对象,我发现我可以做一个类似select * from TableName where Data = 0x4638763849838709 go的查询,其中的值是完整的数据列值.但我希望能够仅对部分数据进行模式匹配,例如 select * from TableName where Data = 0x%3876% go.

For example, using the C# .NET SqlCommand object, I found that I can do a query like select * from TableName where Data = 0x4638763849838709 go, where the value is the full data column value. But I want to be able to pattern match just parts of the data, like select * from TableName where Data = 0x%3876% go.

谢谢.

推荐答案

对于你在问题中给出的例子

For the example you have given in the question

WITH t(c) AS ( SELECT CAST(0x4638763849838709 AS VARBINARY(MAX)) ) SELECT * FROM t WHERE CHARINDEX(0x3876,c) > 0

更多推荐

带有二进制的 SQL WHERE 子句

本文发布于:2023-10-22 08:22:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1516972.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:子句   SQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!