检查现有数据 [英] Checking existing data
本文介绍了检查现有数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好!
我想在插入之前检查数据。
选择@nb = Count(idCustomer)
来自客户
公司如''%''+ @ company +''%''
如果PEUGEOT SA ;已存在,@ nb>如果我输入PEUGEOT,则为0。
另一方面,如果PEUGEOT,则为PEUGEOT。如果我输入PEUGEOT SA,@ nb = 0。
我试图完成ma存储过程:
或@companylike ''%''+公司+''%''
但它不起作用。
提前感谢任何建议。
解决方案
如果一个数据实例可以是数据中其他数据实例的超集< br $> b $ b域,然后不要使用类似的运算符。
例如)data1 =" PEUGEOT SA"
data2 =" PEUGEOT"
这里data1是data2的超集。
所以不要使用like运算符。使用=运算符。
问候,
R.Balaji
" Bonjour" <一个******* @ discussions.microsoft.com>在消息中写道
新闻:O9 ************** @ TK2MSFTNGP09.phx.gbl ...大家好!
我想在插入之前检查数据。
选择@nb = Count(idCustomer)
来自客户
公司喜欢''%' '+ @ company +''%''
如果PEUGEOT SA已存在,@ nb>如果我输入PEUGEOT,则为0。
另一方面,如果PEUGEOT,则为PEUGEOT。如果我输入PEUGEOT SA,则存在,@ nb = 0.
我试图完成ma存储过程:
或@companylike''%''+ company +' '%''
但它不起作用。
提前感谢任何建议。
>
如果你真的想在前面和后面使用带有%的like运算符,那么就这样做
:
set @company =' '%''+ @company +''%''
选择@nb = count(idCustomer)来自客户公司,如@company
Arild
" Bonjour" <一个******* @ discussions.microsoft.com>在消息中写道
新闻:O9 ************** @ TK2MSFTNGP09.phx.gbl ...大家好!
我想在插入之前检查数据。
选择@nb = Count(idCustomer)
来自客户
公司喜欢''%' '+ @ company +''%''
如果PEUGEOT SA已存在,@ nb>如果我输入PEUGEOT,则为0。
另一方面,如果PEUGEOT,则为PEUGEOT。如果我输入PEUGEOT SA,则存在,@ nb = 0.
我试图完成ma存储过程:
或@companylike''%''+ company +' '%''
但它不起作用。
提前感谢任何建议。
>
感谢回答,即使这并没有解决我的问题;-)
我想进行大搜索,所以我需要类似的操作员。
" R.Balaji" < RB ******** @ hotmail.com> écritdansle message de
news:uK ************** @ tk2msftngp13.phx.gbl ...
如果一个数据实例可以是
数据域中的一组超级其他数据实例,那么就不要使用like运算符。
例如data1 =" ; PEUGEOT SA"
data2 =" PEUGEOT"
这里data1是data2的超集。
所以不要使用like运算符。使用=运算符。
问候,
R.Balaji
" Bonjour" <一个******* @ discussions.microsoft.com>在消息中写道
新闻:O9 ************** @ TK2MSFTNGP09.phx.gbl ...大家好!
选择@nb = Count(idCustomer)
来自客户
公司如''%''+ @ company + ''%''
如果PEUGEOT SA已存在,@ nb>如果我输入PEUGEOT,则为0。
另一方面,如果PEUGEOT,则为PEUGEOT。如果我输入PEUGEOT SA,则存在,@ nb = 0.
我试图完成ma存储过程:
或@companylike''%''+ company +' '%''
但它不起作用。
提前感谢任何建议。
>
Hi everybody !
I'' d like to check data before inserting.
Select @nb = Count (idCustomer)
From Customer
Where company like ''%'' + @company+ ''%''
If "PEUGEOT SA" already exists, @nb > 0 if I enter "PEUGEOT".
On the other hand, if "PEUGEOT" exists, @nb =0 if I enter "PEUGEOT SA".
I tried to complete ma stored procedure:
or @companylike ''%'' + company+ ''%''
but it doesn''t work.
Thanks in advance for any suggestion.
解决方案
Hi,
If the one data instance can be a super set of other data instance in a data
domain, then don''t use the like operator.
eg) data1 = "PEUGEOT SA"
data2 = "PEUGEOT"
Here data1 is the superset of data2.
So don''t use the like operator. Use the = operator.
Regards,
R.Balaji
"Bonjour" <an*******@discussions.microsoft.com> wrote in message
news:O9**************@TK2MSFTNGP09.phx.gbl...Hi everybody !
I'' d like to check data before inserting.
Select @nb = Count (idCustomer)
From Customer
Where company like ''%'' + @company+ ''%''
If "PEUGEOT SA" already exists, @nb > 0 if I enter "PEUGEOT".
On the other hand, if "PEUGEOT" exists, @nb =0 if I enter "PEUGEOT SA".
I tried to complete ma stored procedure:
or @companylike ''%'' + company+ ''%''
but it doesn''t work.
Thanks in advance for any suggestion.
If you really want to use the like operator with % in front and end, do it
like this:
set @company = ''%'' + @company + ''%''
select @nb = count(idCustomer) from customer where company like @company
Arild
"Bonjour" <an*******@discussions.microsoft.com> wrote in message
news:O9**************@TK2MSFTNGP09.phx.gbl...Hi everybody !
I'' d like to check data before inserting.
Select @nb = Count (idCustomer)
From Customer
Where company like ''%'' + @company+ ''%''
If "PEUGEOT SA" already exists, @nb > 0 if I enter "PEUGEOT".
On the other hand, if "PEUGEOT" exists, @nb =0 if I enter "PEUGEOT SA".
I tried to complete ma stored procedure:
or @companylike ''%'' + company+ ''%''
but it doesn''t work.
Thanks in advance for any suggestion.
Thanks for answering even if that doesn''t solve my problem ;-)
I''d like to make a large search so I need the like operator.
"R.Balaji" <rb********@hotmail.com> a écrit dans le message de
news:uK**************@tk2msftngp13.phx.gbl...Hi,
If the one data instance can be a super set of other data instance in a data domain, then don''t use the like operator.
eg) data1 = "PEUGEOT SA"
data2 = "PEUGEOT"
Here data1 is the superset of data2.
So don''t use the like operator. Use the = operator.
Regards,
R.Balaji
"Bonjour" <an*******@discussions.microsoft.com> wrote in message
news:O9**************@TK2MSFTNGP09.phx.gbl...Hi everybody !
I'' d like to check data before inserting.
Select @nb = Count (idCustomer)
From Customer
Where company like ''%'' + @company+ ''%''
If "PEUGEOT SA" already exists, @nb > 0 if I enter "PEUGEOT".
On the other hand, if "PEUGEOT" exists, @nb =0 if I enter "PEUGEOT SA".
I tried to complete ma stored procedure:
or @companylike ''%'' + company+ ''%''
but it doesn''t work.
Thanks in advance for any suggestion.
这篇关于检查现有数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文