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 8919357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:00:04+00:00 2026-06-15T06:00:04+00:00

I’m rather new to SQL Server, (did learn SQL back in late 1980’s, DB2

  • 0

I’m rather new to SQL Server, (did learn SQL back in late 1980’s, DB2 if I recall) Today I’m integrating my database layer into SQL, to begin with, SQL Server.

To begin with. As I do today, I will generate in runtime every databases objects, tables objects and indexes programmatically as I do with almost every visual and data object in my projects. That is, I use the visual designing tools very limited.

Every column in my project has a external description file’s (every user has profile which contains these files), just as I do with database key’s and for visual objects as for effect’s as positioning, length, picture-mask, font size, etc. etc. i.e. dynamic forms. Almost every window, grids, filters is created in runtime just as far most of my database connections.

I did build a small test “machine” to create tables in this environment and did well, very easy to create tables within program (I use delphi and ADO)

The problem I encounter is when I flag a column as “autoincrement” or as Identity in SQL Server or if I describe a column as primary key, then SQL Server Management Studio creates automatically a index or key.

That would be ok if I could manage the name it gives this index or key.

Example of this situations:

    AdoCommand.CommandText := Str_SQL;
    TRY
      AdoCommand.Execute;
    FINALLY
      NotiFy_TimeOut ('Table was created', wait_for_one_sec);
    END;

My database engine creates this SQL script which I pass into the string Str_SQL above:

    CREATE TABLE GENGITFL 
    (
      NR INT NOT NULL IDENTITY,
      GJM CHAR(3) NOT NULL,
      HEITI VARCHAR(25) NOT NULL,
      KAUPG REAL NULL,
      SOLUG REAL NULL,
      TOLLG REAL NULL,
      DUMMY VARCHAR(20) NULL,
    UNIQUE (GJM),
    PRIMARY KEY (GJM)
    )

SQL Server creates these two indexes automatically :

  • PK__GENGITFL__C51F17260A463F49
  • UQ__GENGITFL__C51F17277FA3E6E6

I don’t want to use these names for these files, I would prefer names as:

  • IDX_GENGITFL_GJM
  • IDX_GENGITFL_NR

The reason should be obvious in light of my intro, the runtime engine can’t create these names automatically and I consider it not a option to look for what index files are available within system database. If my external description say there should be index, I would like just to create names for the index automatically by using the prefix, IDX_ next the table name and last the field name or name’s with underscore between, as IDX_GENGITFL_GJM etc.

Hope someone understand my poor english and presentation.. I’m rather rusty in english.

Thanks

Edit: After help from marc_s my SQL “script” is like this:

    CREATE TABLE GENGITFL 
    (
      NR INT NOT NULL IDENTITY,
      GJM CHAR(3) NOT NULL,
      HEITI VARCHAR(25) NOT NULL,
      KAUPG REAL NULL,
      SOLUG REAL NULL,
      TOLLG REAL NULL,
      DUMMY VARCHAR(20) NULL,
    CONSTRAINT IDX_GENGITFL_NR UNIQUE (NR),
    CONSTRAINT IDX_GENGITFL_GJM PRIMARY KEY (GJM),
    )

    CREATE INDEX IDX_GENGITFL_HEITI ON GENGITFL (HEITI)

Thanks again.

  • 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-15T06:00:07+00:00Added an answer on June 15, 2026 at 6:00 am

    If you don’t want the system default names – then just specify your own! :

     CREATE TABLE GENGITFL 
        (
          NR INT NOT NULL IDENTITY,
          GJM CHAR(3) NOT NULL,
          HEITI VARCHAR(25) NOT NULL,
          KAUPG REAL NULL,
          SOLUG REAL NULL,
          TOLLG REAL NULL,
          DUMMY VARCHAR(20) NULL,
        CONSTRAINT IDX_GENGITFL_NR UNIQUE (GJM),
        CONSTRAINT IDX_GENGITFL_GJM PRIMARY KEY (GJM)
        )
    

    See those CONSTRAINT (yourownnamehere) before the UNIQUE and the PRIMARY KEY ?

    Now, your constraints are named as you defined.

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

Sidebar

Related Questions

Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am currently running into a problem where an element is coming back from
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have a view passing on information from a database: def serve_article(request, id): served_article
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I have a reasonable size flat file database of text documents mostly saved in

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.