473,396 Members | 1,989 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,396 software developers and data experts.

How to seed or increment NEWID() value

sujathaeeshan
Hi all,

Newid() which creates a unique value of type uniqueidentifier.

Is there any possibolities for seeding or incrementing the NEWID() value.

For example:

create table cust(cust_id uniqueidentifier NOT NULL
DEFAULT newid(),cust_name varchar(60) NOT NULL)

For insertion example:
INSERT cust (cust_id, contact_name) VALUES (newid(), ' ABC ' )
INSERT cust (cust_id, contact_name) VALUES (newid(),' XYZ ' )
INSERT cust (cust_id, contact_name) VALUES (newid(), ' PQR ' )
If i am inserting more then one row detail NEWID() creates uniquevalue.

But i want to increment the NEWID() value is that possible!!!

Plz...can anyone help
Feb 18 '08 #1
1 4211
docdiesel
297 Expert 100+
Hi,

do I understand you right, you'd like to get the first user uid=10000, the next one 10001 and so on? You could use a sequence:

Expand|Select|Wrap|Line Numbers
  1. create sequence
  2.   seq_uid       as integer
  3.   start with    10000
  4.   increment by  1
  5.   minvalue      10000
  6.   no maxvalue
  7.   no cache
  8.   no cycle
  9. ;
The next free uid value would be selectable by "select nextval for seq_uid from sysibm.sysdummy1".

Regards,

Bernd
Feb 18 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: William Ortenberg | last post by:
Can I change the value of a column's identity seed programmatically? If so, how? Thanks in advance.
1
by: A Rothberg | last post by:
Is it possible to use NEWID() as a parameter to a stored procedure in SQL Server 2000. I keep getting a "Line 1: Incorrect syntax near ')'" error. ALTER PROCEDURE dbo.StoredProcedure1 ( @x...
1
by: Ken | last post by:
Need help on the Auto Number or Identity Seed on the Oracle Database I got an Access database that need to be converted to Oracle 9i. Somehow the Trigger we created to simulate the "AUTO NUMBER"...
4
by: vivek7006 | last post by:
By default, randomm module uses the timestamp to generate the seed value. Is it possible to know what that seed value is? import random random.random() # How do I print the current value of...
7
by: Yannick Turgeon | last post by:
Hello all, I'm using SS2K on W2k. I'v got a table say, humm, "Orders" with two fields in the PK: OrderDate and CustomerID. I would like to add an "ID" column which would be auto-increment...
10
by: Leon | last post by:
I know by default the random number generator use the time, but what is the best seed I can used in my web application? The Program generate 6 unique random numbers and load each of them in a...
1
by: Pauljh | last post by:
Hi All, I have a web page which builds a hidden table, as (based on certain criteria) people can have multiple version of this table, not a problem. But I need each table to have a unique id...
2
by: mr.Hyde | last post by:
Hi, I am working with mscrm database. the Accounts has UniqueIdentifierID, so I am trying to use as parameter value in sqlcommand "NewId();", it doesnt works becouse, ExecuteNonQuery pass my...
3
by: Cindy | last post by:
I'm trying to use the NEWID function in dynamic SQL and get an error message Incorrect syntax near the keyword 'ORDER'. Looks like I can't do an insert with an Order by clause. Here's the code:...
1
sujathaeeshan
by: sujathaeeshan | last post by:
Hi all, Newid() which creates a unique value of type uniqueidentifier. Is there any possibolities for seeding or incrementing the NEWID() value. For example: create table cust(cust_id...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.