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

  • Home
  • SEARCH
  • 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 8481297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:31:42+00:00 2026-06-10T19:31:42+00:00

I have a ms sql table PRODUCTS. And it has three columns ID (int),NAME

  • 0

I have a ms sql table PRODUCTS.
And it has three columns ID (int),NAME (nvarchar),TSTAMP (timestamp)

I want to get new inserted row’s both id and timestamp (like multiple select scope_identity).
I can achieve that in sql as following:

INSERT INTO PRODUCTS (NAME)
OUTPUT inserted.ID,inserted.TSTAMP
VALUES ('Example Product')

But how can i read it in vb.net with sqlclient.sqlcommad on insertation? Which function of sqlcommand do i have to use and how? ExecuteReader maybe?

  • 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-10T19:31:44+00:00Added an answer on June 10, 2026 at 7:31 pm

    Using the ExecuteReader() method of SqlCommand would work the same as with SELECT.

    OUTPUT clause works like a SELECT statement but its usage differs in
    INSERT, UPDATE and DELETE commands

    Here’s a sample code. Try it.

    Dim connString As String = "server=Test; database=Test;" + _
                               "uid=sa; pwd="
    Dim conn As New SqlConnection(connString)
    
    Dim cmdString As String = "INSERT INTO PRODUCTS (NAME) " + _
                              "OUTPUT inserted.ID,inserted.TSTAMP " + _
                              "VALUES ('Example Product')"
    Dim cmd As New SqlCommand(cmdString, conn)
    conn.Open()
    Dim reader As SqlDataReader = cmd.ExecuteReader()
    conn.Close()
    

    Here’re some links

    Running The OUTPUT Clause From C#

    Implementing the OUTPUT Clause in SQL Server 2008

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

Sidebar

Related Questions

I have a SQL Server DB that has a table of products, and another
I have an SQL table like this : sales(product,timestamp) I want to display a
I have a Products table in SQL Server database, it has an ID column
Say I have a table that has the following columns: AutoID (PK, int not
I have a table of products, and I need to write an SQL query
I have a SQL table in which some columns, when viewed in SQL Server
I have a SQL table BookChapters with over 20 millions rows. It has a
I have 2 tables. Table 1 has Product ID and Product Name (each row
I have a Category table which has 3 fields i'm interested in: ID, Name,
I have a SQL Server 2008 database. This database has a table called Product,

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.