Reputation: 24297
I don't know how to phrase this question, but I'm trying to do this:
alter table [TEMP]
add SEQID int identity(1,1)
This works; however, what I really need is a float column instead of an int:
alter table [TEMP]
add SEQID **FLOAT** identity(1,1)
I think this is illegal. Please let me know if it is not. Is there a work around to getting a float ID column?
Edit: Is there a way to create the identity column as int, then remove the identity attribute, and then convert the column to a float?
Upvotes: 0
Views: 1358
Reputation: 1270723
You can do what you want as:
create table temp (
id int identity(1,1),
fid as cast(id as float)
)
This adds the id as an integer but then has another column that is computed by converting it to float.
Why are you creating new ids for a legacy system?
Or, you can add the computed column to an existing table:
alter table temp add fid as cast(id as float)
Upvotes: 3
Reputation: 13
I don't know if I understand why you want a floating point ID. That column is usually just stored as an int (bigint, smallint, depends on the table...) but an int will uniquely identify each row of the table sufficiently to allow you to query each of them without data contamination. You just have to make sure to Join the tables correctly.
If you're really sure about using float, then I think this would suffice, unless I'm missing something:
alter table [TEMP]
add SEQID float identity(1,1)
Upvotes: -1