| Author |
Topic |
|
kashyapsid
Yak Posting Veteran
78 Posts |
Posted - 2010-04-07 : 03:32:40
|
| Can we change a identity column to a varchar through coding.the column name is EMPID table name EmpsKaShYaP |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-04-07 : 03:37:49
|
Can you make more clear what you want to do? No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
|
|
kashyapsid
Yak Posting Veteran
78 Posts |
Posted - 2010-04-07 : 03:52:27
|
| Mr.fredActually if we make any data deletion in the table the sequence of the identity column will be changed. If we can insert the data them we will modify it.Ex:- Empid is 1,2,3,4....N. If we delete some data of some rows i,e 6,7,8 rows have deleted then the sequence of the numbers will be changed.So, I am asking if we add data into identity column like giving empid 6 then we will get in a sequential mannerKaShYaP |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-04-07 : 03:59:16
|
Ok that has nothing to with changing the column to varchar.Why do you bother about the sequence of that identity column?Gaps? That should be nothing to care about. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-04-07 : 04:01:14
|
| for that you need to set identity insert on and pass a explicit value. Actually you dont need to worry about it as you can still get data in order you want with gaps.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2010-04-07 : 04:01:17
|
| So you want an ID that has no gaps?This will change over time of course, so you cannot use it as the sense of "Employee ID" - you will need another, non changing, field for that.Is this just for reports? If so a sequential "row number" can be generated at the time you select the data - would that do instead? |
 |
|
|
kashyapsid
Yak Posting Veteran
78 Posts |
Posted - 2010-04-07 : 04:16:06
|
| Thank You all for consideringKaShYaP |
 |
|
|
kashyapsid
Yak Posting Veteran
78 Posts |
Posted - 2010-04-07 : 04:34:24
|
| Mr.Visakh16Can you give coding of the statement of yours PlzKaShYaP |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-04-07 : 04:42:25
|
quote: Originally posted by kashyapsid Mr.Visakh16Can you give coding of the statement of yours PlzKaShYaP
something likeSET IDENTITY_INSERT yourTable ONINSERT INTO yourTable(IDColumn,othercolumns..)VALUES(@ReqdIDvalue,...)SET IDENTITY_INSERT yourTable OFF ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2010-04-07 : 04:46:32
|
| Just to check:1) Is this the main Employee ID that people / computer programs refer to the record by?or2) is it just a "Row number" so you can display the employees "in order"? |
 |
|
|
kashyapsid
Yak Posting Veteran
78 Posts |
Posted - 2010-04-07 : 07:55:25
|
| it is a computer program automatically generating the EmpId numberKaShYaP |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2010-04-07 : 09:07:14
|
| So ... if someone leaves you want to re-use their number for a new employee?Why not just allocate them the next number (ignoring any numbers / gaps for people who have left)? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-04-07 : 12:46:50
|
| you will at least avoid difficulty of doing this manually by just making it identity and not worrying abt gaps------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
kashyapsid
Yak Posting Veteran
78 Posts |
Posted - 2010-04-08 : 01:00:33
|
| ok thats fine thanks once againKaShYaP |
 |
|
|
|