如何检查字符串与数据库中的相同 [英] How to Check string is Same as in Database
本文介绍了如何检查字符串与数据库中的相同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我有文本框数据将数据插入sqlserver。
例如:txtbox.Text = Dotnet Framework;
用以下查询检查Dotnet Framework是否存在并且工作正常
Hi
I have textbox data which am inserting the data into sqlserver.
eg:txtbox.Text="Dotnet Framework";
For checking whether "Dotnet Framework " existed or not with the below query and it works fine
ALTER PROCEDURE [dbo].[spCheckDuplicateName]
(@CheckValue varchar(100),
@ReturnValue int out)
AS
SET NOCOUNT ON
BEGIN
IF Exists (SELECT TOP 1 Name From tblName WHERE Name = @CheckValue)
set @ReturnValue = 3;
Else
SET @ReturnValue=0;
END
但如果再次输入字符串为DotnetFrameWork ,它将它视为新名称和插入,我不想插入它。
您可能会觉得这是一个愚蠢的问题,但我无法做到它。
任何想法都可以达到这个目的。所以我不能用空格插入相同的名字。
but if enter again string as"DotnetFrameWork", it considering it as new name and inserting,which i dont want to insert it.
You may feel its a silly question to ask but i couldn't do it.
Any idea to achieve this.So that i can't inserting same name with out space.
推荐答案
您可能想要查看SOUNDEX
和DIFFERENCE
。它们不仅仅是空格,而且可以很好地检查以过滤掉类似的条目。
http://technet.microsoft.com/en-us/library/ms189282%28v=sql.105%29.aspx [ ^ ]
祝你好运!
You might want to check outSOUNDEX
andDIFFERENCE
. They go further than just spaces but could be a good check to filter out similar entries.
http://technet.microsoft.com/en-us/library/ms189282%28v=sql.105%29.aspx[^]
Good luck!
这篇关于如何检查字符串与数据库中的相同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文