In one of my project there was an requirement to display the Phone Numbers formatted according to US Standards(eg: 123-456-7890).
I initially thought I have to insert the '-' symbol at the index values. But my goodness, this was made so easy in .Net String Formatting.
For Example:
Dim phone as Integer = 123456890
String.Format("{0:###-###-####}", phone)
This will be displayed as 123-456-7890
Be a smart coder. Let me know if its useful. Happy Coding.
Friday, September 25, 2009
Wednesday, September 2, 2009
Reseed Identity Column in a Table
Today in our web application we have to make a major release to production. Everything went fine but we have lot of test entries in the production. Our identity column of the User table increased from 1342 to 1456 because of the test entries. Myself and a friend of mine read an article for resetting the Identity Column. So after deleting the entries this is what you have to do.
Resetting Current Identity Value to New Value
Resetting Current Identity Value to New Value
use DBNAME
go
dbcc checkident(TABLENAME, reseed,seed value)
For Eg:
dbcc checkident(dbo.[User],reseed,1342)
which served my purpose.
To Get Current Identity Value
Also this seems to be useful. This gives the current identity value of the table.
use DBNAME
go
dbcc checkident(TABLENAME, noreseed)
For Eg:
dbcc checkident(dbo.[User],noreseed)
Please let me know your thoughts. Have a good day.
Subscribe to:
Posts (Atom)