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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:23:31+00:00 2026-05-30T13:23:31+00:00

Consider one table tbl1 with ID and Name . A table-valued parameter params with

  • 0

Consider one table tbl1 with ID and Name.
A table-valued parameter params with ID.

I need to duplicate the rows in tbl1 which have the ID contained in params.
I am trying to insert like this

insert into tbl1(Name,somevalues..) 
   select tbl1.Name, tbl1.somevalues..
   from @params p 
   inner join tbl1 on tbl1.ID=p.ID  -- here ID is identity (PK).

But after insertion, it is found that the order of insertion is different. If I am running the select query alone, it will display the ID based on @params (TVP). But the same query when I used after insert will perform in a different way.

order in TVP / Select Query – A
order when insert using Select Query – B

 A       B 
370294  370294
368702  368702
369157  368504
368914  368505
368505  368914
368504  369157
368508  368506
368506  368507
368507  368508
368912  368637
368637  368638
368638  368639
368639  368912
368915  368915
368641  368641

There some ID’s which are different in order.

What will be the issue for different order?

How can I insert values in the same order as in my TVP ?

Thanks in advance.

  • 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-05-30T13:23:32+00:00Added an answer on May 30, 2026 at 1:23 pm

    Always: ORDER is arbitrary without an ORDER BY.

    This means that even if you did use ORDER BY for the INSERT, then a later SELECT isn’t guaranteed to return with this order unless you use ORDER BY on the SELECT.

    In other words: there is no implied or natural order to a table or view.

    You can only have a defined order with ORDER BY

    Edit

    However. it should be noted that INNER JOINs are both commutative and associative. That is, you get the same results. You’re asking about ORDER which I answered above

    For more, see

    • How order of joins affect performance of a query
    • how to best organize the Inner Joins in (select) statement
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider an Excel sheet with one column of bad data. We have a table
Consider these two classes mapped to the same table. One is readonly via mutable=false.
Out of the following queries, which method would you consider the better one? What
Consider the following situation: We have two Localizable.string files, one in en.lproj and one
I need to copy some data from one table to another in Oracle, while
Im trying to copy over data from one table to another in the same
I have 2 tables. One table is 'headings' & contains Headings and the other
I have several TableLayoutPanels, each of which displays a category of name/value information in
Our application has a table which stores all transactions records of clients in one
Consider the table SAMPLE: id integer name nvarchar(10) There is a stored proc called

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.