SQL自动增量范围或排除数字

时间:2016-03-03 09:22:11

标签: sql sql-server auto-increment identity-insert

我正在尝试在sql中的自动增量列中添加范围或排除数字。

我们有一个关于工作号的自动增量列,因为每个工作都是唯一的。问题是我们将自己视为客户端,作业编号为99999,其他作业编号以10500结尾。当自动增量发生时,从99999开始。这有一种方法可以排除这个或者我是否必须手动设置IDENTITY_INSERT并自行插入ID?

提前致谢

1 个答案:

答案 0 :(得分:0)

您可以在" Microsoft SQL Server"中设置自动增量。
检查:SQL-How to Insert Row Without Auto incrementing a ID Column?
通过这种方式,您可以自己设置ID。

<nav id="menu" class="navbar navbar-default">

            <div class="container-fluid" id="fullNav">

                <div class="navbar-header">

                    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbarBody" aria-expanded="false" id="collapsedNavbarExpand">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar" ></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>

                    <a class="navbar-brand" href="index.html">Logo</a>

                </div>

                <div class="collapse navbar-collapse" id="navbarBody">

                    <ul class="nav navbar-nav">

                        <li class="dropdown">

                            <a href="#" class="dropdown-toggle navOption" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                                Tourism 
                                <span class="caret"> </span>

                            </a>

                            <ul class="dropdown-menu">

                                <li> <a href="../Pages/tourismHub.html"> <b> Tourism Hub </b> </a> </li>
                                <li role="separator" class="divider"></li>
                                <li> <a href="../Pages/eatingOut.html"> Eating Out </a> </li>
                                <li> <a href="../Pages/attractions.html"> Attractions </a> </li>
                                <li> <a href="../Pages/events.html"> Events </a> </li>
                                <li> <a href="../Pages/history.html"> Town History </a> </li>

                            </ul>

                        </li>

                        <li class="dropdown">

                            <a href="#" class="dropdown-toggle navOption" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">

                                Residents
                                <span class="caret"> </span>

                            </a>

                            <ul class="dropdown-menu">

                                <li> <a href="../Pages/residentsHub.html"> <b> Residents Hub </b> </a> </li>
                                <li role="separator" class="divider"></li>
                                <li> <a href="../Pages/events.html"> Events </a> </li>
                                <li> <a href="../Pages/eatingOut.html"> Eating Out </a> </li>
                                <li> <a href="../Pages/history.html"> History </a> </li>

                            </ul>

                        </li>

                        <li class="dropdown">

                            <a href="#" class="dropdown-toggle navOption" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">

                                Prospective Residents
                                <span class="caret"> </span>

                            </a>

                            <ul class="dropdown-menu">

                                <li> <a href="../Pages/prospectiveResidentsHub.html"> <b> Prospective Residents Hub </b> </a> </li>
                                <li role="separator" class="divider"></li>
                                <li> <a href="../Pages/realEstate.html"> Real Estate </a> </li>
                                <li> <a href="../Pages/attractions.html"> Attractions </a> </li>
                                <li> <a href="../Pages/history.html"> Town History </a> </li>
                                <li> <a href="../Pages/eatingOut.html"> Eating Out </a> </li>

                            </ul>

                        </li>

                        <li class="dropdown">

                            <a href="#" class="dropdown-toggle navOption" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">

                                Locations
                                <span class="caret"> </span>

                            </a>

                            <ul class="dropdown-menu">

                                <li> <a href="../Pages/locationsHub.html"> <b> Locations Hub </b> </a> </li>
                                <li role="separator" class="divider"></li>
                                <li> <a href="../Pages/marina.html"> Marina </a> </li>
                                <li> <a href="../Pages/highStreet.html"> High Street </a> </li>
                                <li> <a href="../Pages/parishWharf.html"> Parish Wharf </a> </li>
                                <li> <a href="../Pages/lakeGrounds.html"> Lake Grounds </a> </li>

                            </ul>

                        </li>

                        <li> <a href="../Pages/map.html" class="navOption"> Map </a> </li>

                    </ul>

                </div>

            </div>

        </nav>