473,320 Members | 1,862 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Checking existing data

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.
Nov 16 '05 #1
11 1424
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.

Nov 16 '05 #2
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.

Nov 16 '05 #3
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.


Nov 16 '05 #4
It's what I made but this request does't return any result if the company
name's length stored in the database is shorter than the name entered:

Select @nb = Count (idCustomer)
From Customer
Where company like '%PEUGEOT SA%'

@nb = 0 if there's already a company PEUGEOT.

Thanks all the same.

"Arild Bakken" <ar*****@hotmail.com> a écrit dans le message de
news:%2****************@TK2MSFTNGP10.phx.gbl...
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.


Nov 16 '05 #5
Hi,

Then you need to check if the text is LIKE the column OR if the column is
LIKE the text :

Select @nb = Count (idCustomer)
From Customer
Where ( company like '%' + @company+ '%' ) OR ( @company like '%' + company
+ '%' )

The query above should match your example.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"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.

Nov 16 '05 #6
Hi Bonjour,

"Bonjour" <an*******@discussions.microsoft.com> wrote in message
news:eu**************@TK2MSFTNGP10.phx.gbl...
It's what I made but this request does't return any result if the company
name's length stored in the database is shorter than the name entered:

Select @nb = Count (idCustomer)
From Customer
Where company like '%PEUGEOT SA%'

@nb = 0 if there's already a company PEUGEOT.

Thanks all the same.


It would help if you could be more specific about the criteria you are
looking for. That being said, this might work for you:

Select @nb = Count (idCustomer)
From Customer
Where company like '%PEUGEOT SA%'
Or 'PEUGEOT SA' like '%' + company + '%'

Regards,
Daniel
Nov 16 '05 #7
Thanks everybody for your answers but your solution is what I made :

Select @nb = Count (idCustomer)
From Customer
Where company like '%' + @company + '%'
or @company like '%' + company + '%'

And it doesn't work : after a long time, the server crashes...
"Bonjour" <an*******@discussions.microsoft.com> a écrit dans le message de
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.

Nov 16 '05 #8
Hi,

What is the hardware and datasize of the server?

Does the server crash really ? if so what error you get?

Like is a very expensive operation .

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Bonjour" <an*******@discussions.microsoft.com> wrote in message
news:es**************@tk2msftngp13.phx.gbl...
Thanks everybody for your answers but your solution is what I made :

Select @nb = Count (idCustomer)
From Customer
Where company like '%' + @company + '%'
or @company like '%' + company + '%'

And it doesn't work : after a long time, the server crashes...
"Bonjour" <an*******@discussions.microsoft.com> a écrit dans le message de
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.


Nov 16 '05 #9
I have a Duron 1,3 GHz with 256 Mo RAM.
The Customer table only has 500 records.

The message is "Application not avalaible" (the message for a asp.net
application in red letters) in my browser.

I have just noticed that the query works in the query analyser ! (the db
server is also my personal computer)
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> a
écrit dans le message de news:e1**************@TK2MSFTNGP11.phx.gbl...
Hi,

What is the hardware and datasize of the server?

Does the server crash really ? if so what error you get?

Like is a very expensive operation .

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Bonjour" <an*******@discussions.microsoft.com> wrote in message
news:es**************@tk2msftngp13.phx.gbl...
Thanks everybody for your answers but your solution is what I made :

Select @nb = Count (idCustomer)
From Customer
Where company like '%' + @company + '%'
or @company like '%' + company + '%'

And it doesn't work : after a long time, the server crashes...
"Bonjour" <an*******@discussions.microsoft.com> a écrit dans le message de 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.



Nov 16 '05 #10
Hi,

You have another trouble then, it's not the DB stuff

paste here the complete page of error

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Bonjour" <an*******@discussions.microsoft.com> wrote in message
news:u9**************@TK2MSFTNGP09.phx.gbl...
I have a Duron 1,3 GHz with 256 Mo RAM.
The Customer table only has 500 records.

The message is "Application not avalaible" (the message for a asp.net
application in red letters) in my browser.

I have just noticed that the query works in the query analyser ! (the db
server is also my personal computer)
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> a
écrit dans le message de news:e1**************@TK2MSFTNGP11.phx.gbl...
Hi,

What is the hardware and datasize of the server?

Does the server crash really ? if so what error you get?

Like is a very expensive operation .

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Bonjour" <an*******@discussions.microsoft.com> wrote in message
news:es**************@tk2msftngp13.phx.gbl...
Thanks everybody for your answers but your solution is what I made :

Select @nb = Count (idCustomer)
From Customer
Where company like '%' + @company + '%'
or @company like '%' + company + '%'

And it doesn't work : after a long time, the server crashes...
"Bonjour" <an*******@discussions.microsoft.com> a écrit dans le
message
de 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.
>
>



Nov 16 '05 #11
Thanks all for your help.

My trouble was due to the fact I forgot a relation between 2 tables. :-/
"Bonjour" <an*******@discussions.microsoft.com> a écrit dans le message de
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.

Nov 16 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

67
by: Steven T. Hatton | last post by:
Some people have suggested the desire for code completion and refined edit-time error detection are an indication of incompetence on the part of the programmer who wants such features. ...
2
by: R Bolling | last post by:
I am using a routine to check to see if a phone number (PK) has alread been entered, and takes the user to that record if it is found -- as follows: Private Sub...
7
by: RBohannon | last post by:
I'm using A2K. I'm inputing data from a text file into my DB, and I need to check for the data already existing in the DB. If it's already in the DB, I don't want to reenter it. The two...
5
by: BerkshireGuy | last post by:
Hello everyone, I have a bond form that a user uses to enter data. One of my fields, is PolicyNumber. I added some code on the Before Update event of txtPolicyNumber that checks to see if...
0
by: D. Shane Fowlkes | last post by:
OK - I'm looking for the best approach on how to do this. I have a form page where the user can edit their "Profile" (data) which is in SQL Server. It's your basic company information - address,...
0
by: D. Shane Fowlkes | last post by:
OK - I'm looking for the best approach on how to do this. I have a form page where the user can edit their "Profile" (data) which is in SQL Server. It's your basic company information - address,...
26
by: Army1987 | last post by:
Is this a good way to check wheter a file already exists? #include <stdio.h> #include <stdlib.h> int ask(const char *prompt); typedef char filename; int main(int argc, char *argv) { FILE...
125
by: jacob navia | last post by:
We hear very often in this discussion group that bounds checking, or safety tests are too expensive to be used in C. Several researchers of UCSD have published an interesting paper about this...
4
by: winningElevent | last post by:
Hi everyone, I have a question would like to ask. So far I know how to retrieve files from device, but sometimes device takes so long to produce file so I want my desktop to keep checking every...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.