MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old March 23rd, 2004, 02:21 PM
Qnavry Qnavry is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 11 Qnavry User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 9 m 23 sec
Reputation Power: 0
Inserting Nonduplicate data

How would can i insert a range of numbers without inserting duplicate value for a certain field? Here is what i have to insert the range.

declare @id int,
@id2 varchar(10)

set @id = 1234
while @i < 4321 begin
set @id2 = 'ID_' + cast(@i as varchar(9))
INSERT INTO tblxxxx (Axxx, Bxxxx, Cxxxxxx)
Values (@id2,1,31,40)
set @i = @i + 1
end

Reply With Quote
  #2  
Old March 24th, 2004, 07:07 PM
sypher sypher is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Montreal
Posts: 92 sypher User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 10 sec
Reputation Power: 5
you can always build index on that field and put the Create unique constraint. This way when you'll insert you'll get a error message

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Inserting Nonduplicate data


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway