Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8940737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:07:10+00:00 2026-06-15T11:07:10+00:00

Inside my SQL Server database I got this as my ID for example SSK0000001

  • 0

Inside my SQL Server database I got this as my ID for example SSK0000001.

I want it to auto-increment in my system and also the last number of ID e.g.”1″ (after another new record it will become SSK0000002) is update in my SQL Server database.

I know it can be done with set auto-increment inside database but now my ID is nchar.

Anyone could help will be appreciate.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T11:07:12+00:00Added an answer on June 15, 2026 at 11:07 am

    You can cast right side to int and increment:

    declare @next int
    select @next = convert( int, right( max( id ), 7 ) )  + 1
    from your table 
    

    then insert as:

    insert into ... (Id, ...)
    values (   'SDK' + right( '0000000' + rtrim(ltrim( str( @next ) ) ), 7 ), ... )
    

    But this is the most dirty solution as you can take:

    • This cause a lot of database locks (because aggregation function)
    • Slowest than autoincrement
    • Lot of code to keep.

    I suggest to you to move to an autoincrement data type

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a (SQL Server) database table called Category. And another database table called
So I have this VB.Net Application. It uses SQL Server database, for which it
I've got the following T-SQL code below that's working from inside of SQL Server
I have an SQL server 2008 database instance on one machine. Now I want
I am trying to set up a connection to my SQL server inside of
I'm using SQL Server 2005 Analysis Services and I'm trying to calculate distance inside
I want to use magic function __set() and __get() for storing SQL data inside
I want to use CLR table-valued function in SQL Server 2008, which accesses a
I've got a strange problem with indexing PDF files in SQL Server 2005, and
I am trying to generate random data for my sql server database. Ive created

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.