Skip to content

Tarik Billa

  • Web Development
    • html
    • vue.js
    • laravel
    • css
    • javascript
    • jquery
    • node.js
    • php
    • asp.net
  • Programming
    • python
    • java
    • c
    • c++
    • c#
  • git
  • android

select-into

SQL Server ‘select * into’ versus ‘insert into ..select *

December 22, 2023 by Tarik

The select * into table1 from table2 where 1=1 creates table1 and inserts the values of table2 in them. So, if the table is already created that statement would give an error. The insert into table1 select * from table2 only inserts the values of table2 in table1.

Categories sql-server Tags select-into, sql-server Leave a comment

Preserving ORDER BY in SELECT INTO

July 29, 2023 by Tarik

I know this is a bit old, but I needed to do something similar. I wanted to insert the contents of one table into another, but in a random order. I found that I could do this by using select top n and order by newid(). Without the ‘top n’, order was not preserved and … Read more

Categories sql-server Tags select-into, sql-order-by, sql-server, tsql Leave a comment

Select multiple columns into multiple variables

June 30, 2023 by Tarik

Your query should be: SELECT T1.DATE1, T1.DATE2, T1.DATE3 INTO V_DATE1, V_DATE2, V_DATE3 FROM T1 WHERE ID=’X’;

Categories sql Tags oracle, plsql, select-into, sql Leave a comment

SELECT INTO and “Undeclared variable” error

April 3, 2023 by Tarik

INSERT … SELECT http://dev.mysql.com/doc/refman/5.1/en/insert-select.html INSERT INTO newsletter_to_send SELECT id_subscriber FROM subscribers PS: are you sure you don’t need in WHERE clause?

Categories mysql Tags mysql, mysql5, select-into Leave a comment

Tarik Billa

Software Engineer
tarikbilla@gmail.com
+8801884414000
  • Reuse a hash in YAMLApril 17, 2024
  • Dockerfile: how to redirect the output of a RUN command to a variable?April 16, 2024
  • How to cd to a directory with spaces in the directory name?April 16, 2024
  • Maximum MIME type length when storing the type in a databaseApril 16, 2024
  • What is the difference between Unit, Integration, Regression and Acceptance Testing?April 16, 2024
© 2026 Tarik Billa