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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:20:30+00:00 2026-06-15T13:20:30+00:00

I need to write an insert statement into a table the columns looks like

  • 0

I need to write an insert statement into a table the columns looks like this

  • demandtypeid (PK, FK, int, not null)
  • characvalueid (PK, FK, int, not null)
  • percentage (int null)
  • lastuser (varchar(100), null)
  • lastedited (datetime, null)

Here is the INSERT statement. Notice the there is not values at the

value( ,  , 'Bob')

as I think that’s where the auto-increment command should go

insert into tr_demandtypecharac(demandtypeID, characvalueid, lastuser) 
values(  , , 'Bob')

Please help with a simple little statement

I just want to know how to manually insert into this table

Here’s my table structure:

CREATE TABLE [dbo].[tr_demandtypecharac](
[demandtypeid] [int] NOT NULL,
[characvalueid] [int] NOT NULL,
[percentage] [int] NULL,
[lastuser] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[lastedited] [datetime] NULL,
 CONSTRAINT [PK_tr_dtc_pkey] PRIMARY KEY CLUSTERED 
(
[demandtypeid] ASC,
[characvalueid] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
 ) ON [PRIMARY]

ALTER TABLE [dbo].[tr_demandtypecharac]  WITH CHECK 
ADD CONSTRAINT [FK_tr_dtc_cvid] 
FOREIGN KEY([characvalueid]) REFERENCES [dbo].[tr_characvalue] ([characvalueid])

ALTER TABLE [dbo].[tr_demandtypecharac]  WITH CHECK 
ADD CONSTRAINT [FK_tr_dtc_dtid] 
FOREIGN KEY([demandtypeid]) REFERENCES [dbo].[tr_demandtype] ([demandtypeid])
  • 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-15T13:20:31+00:00Added an answer on June 15, 2026 at 1:20 pm

    Given the CREATE TABLE statement you posted, without auto-increment (aka identity) columns, you would insert providing all columns and values, like this:

    insert into tr_demandtypecharac(
           demandtypeid, characvalueid, 
           percentage, lastuser, lastedited) 
    values(2, 3, 80, 'Bob', '01/01/2012')
    

    If, however, you do make them auto-increment by changing the CREATE TABLE to:

    CREATE TABLE [dbo].[tr_demandtypecharac](
    [demandtypeid] [int] NOT NULL IDENTITY(1,1),
    [characvalueid] [int] NOT NULL IDENTITY(1,1),
    [percentage] [int] NULL,
    [lastuser] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [lastedited] [datetime] NULL,
     CONSTRAINT [PK_tr_dtc_pkey] PRIMARY KEY CLUSTERED 
    (
    [demandtypeid] ASC,
    [characvalueid] ASC
    )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
     )
    

    Then you would insert providing all non-identity (non-autoincrement) columns like this:

    insert into tr_demandtypecharac(
          percentage, lastuser, 
          lastedited) 
    values(80, 'Bob', '01/01/2012')
    

    However, it is not common to have more than one column as an identity (autoincrement) column, and generally, this column is the only PRIMARY KEY column.

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

Sidebar

Related Questions

I need to write some code to insert around 3 million rows of data.
I need to write a simple C# .NET application to retrieve, update, and insert
I have some sprocs that need a temp table. In order not to hardcode
I need to insert a record to table if the record doesn't exist, and
I have a table which has id and statement columns, statement column contains statement
I was lazy and write an insert statement with DateTime.Now. It occur to me
I want to insert many thousand records and I need this to be fast.
I need some help with creating an insert statement for an Access 2007 database
Ive spent 4 hours trying to write a simple insert a datetime into a
I need to write a sproc which performs some INSERTs on a table, and

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.