Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SQL 2005, check exist before insert.

Posted on 2009-04-06
2
Medium Priority
?
481 Views
Last Modified: 2012-05-06
Please tell me how can I check existing data before insert new value.
for example: in my database has this value:   Sample Test.
So when user input new values like: sample test, Sample Test, Sample test, sample Test. SQL will prevent it.

How can I do?
Please help me!
0
Comment
Question by:Mr_Bach
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 14

Expert Comment

by:Binuth
ID: 24084092
IF NOT EXISTS(Select 1 from tablename where fieldname ='Sample test')
begin
-- insert stmt
end
0
 
LVL 14

Accepted Solution

by:
Binuth earned 2000 total points
ID: 24084122
use COLLATE SQL_Latin1_General_CP1_CI_AS - for non- case senstive search
IF NOT EXISTS (SELECT 1 FROM TableName WHERE feildName COLLATE SQL_Latin1_General_CP1_CI_AS = 'Sample Test' )
BEGIN
 
	-- Insert Statement
 
END

Open in new window

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will describe one method to parse a delimited string into a table of data.   Why would I do that you ask?  Let's say that you need to pass multiple parameters into a stored procedure to search for.  For our sake, we'll say that we wa…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question