March 10, 2008 at 5:33 am
Heloo all,
how i show messege if i entering details already stored in my sqlserver 2000 database.
This's my problem.
I have insert some customer details.But if i try to add same customer details again and again i want to show it already inserted. So let me know how i do that thing.................
Now im doing it like this
SELECT *
FROM tblInsertDetails
WHERE (Status = 1) AND (RefNumber LIKE @InsertID)
Use select statement and getting some dataset and if that dataset is null then i gave permission to insert that record. But i want to learn it better way to do inside the sql or some way.
thankyou
March 10, 2008 at 6:15 am
Lookup RAISERROR in Books Online... that should do it.
--Jeff Moden
Change is inevitable... Change for the better is not.
March 11, 2008 at 1:20 am
March 11, 2008 at 4:52 am
Yes, that would be the safe guard... but, I recommend that you don't rely on that safeguard as a programming tool... takes a comparitively long time to have an error rather than check for existance and insert only when unique... especially of batches of a couple thousand where the whole batch could be reject if one is not unique. Sure, the "Ignore Dupes" setting for unique indexes will keep the batch from rejecting, but again, relatively expensive and doesn't tell you a bloody thing about which rows were dupes.
And, such indexing actually slows down bulk inserts... a LOT! Best thing to do is import everything into a staging table with a surrogate PK and do a high speed dupe check (and other checks) to mark either bad or good rows. Then, use criteria to ignore "bad" rows.
I never import directly to final tables anyway. Causes too many locks on "active tables" while you're trying to validate rows. Allowing indexes to do your work for you is "programming by exception" and it will make for slow code.
--Jeff Moden
Change is inevitable... Change for the better is not.
March 11, 2008 at 6:22 am
Thanks, Jeff, for enlightening us. I do not know if I will encounter in a lifetime any of the issues you encounter every working day; your experience is of VLDB environments, mine is trifling in comparison. As I always say, I learn something new every day.
March 11, 2008 at 6:28 am
Thanks for the feedback, GoodGuy... but it's all the same... just bigger, that's all 😉
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply