var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: IDENTITY Crisis: Converting an identity column to non-integer datatype
I'm new to SQL and need to know if the following is possible:
I have a table with the following fields:
Item - varchar(20)
IDNo - int, IDENTITY (1,1)
I need a third column to do the following:
1) Serve as a Primary Key for the table
2) Be a computed column of the form Item+IDNo
3) Be able to establish relationships with Foreign Keys
For example: Item = X, IDNo = 1, KeyColumn = X1
try this, it will work.
[B]create table item_details (IDNo int identity(1, 1), Item varchar(20), item_id as convert(nvarchar, Item) + convert(nvarchar, IDNo) persisted primary key );
tablename = item_details.
we are converting datatype of IDNo into nvarchar and we need to declare auto computed field as persisted then we can create a table.
if you insert value in item field, automaticallt it will generate an autoincrement Slno and convert ito nvarchar and combines with Item.
Yes, stop what you are doing and Make Iyem, IDNo a Composite PK
Originally Posted by Bleuchild
Why? I have no idea
Tags for this Thread