Skip to content
Advertisement

Tag: sql-insert

Alternate approach to WITH CTE and large UNION query

I’d like to rework a script I’ve been given. The way it currently works is via a WITH CTE using a large number of UNIONs. Current setup We’re taking one record from a source table, inserting it into a destination table once with [Name] A then inserting it again with [Name] B. Essentially creating multiple rows in the destination, albeit

Msg 100, Level 16, State 0, Line 109 insert statement error

While inserting the values in this table error occurred.and after adding constraints it’s not working on that condition too. What to do?? Answer When you have defined relationship then data should be present in Parent table first before inserting the data in child table otherwise data in child table is called as orphan and system will not allow you to

For all entries in one table, add to another table

Database looks like this: table1 table2 I want to make a query that passes the same data for all ID’s into table2. So after the query the database would look like the following: table1 table2 I’ve tried to make some INNER JOIN queries, but I can’t seem to make it work. Any suggestions? Answer Do you want this? Normally, ids

How to insert column of other table in postgresql

I want to insert a column of other table and one parameter of this table have a hard coded value. I want to iterate this value with the each return value of other table column. How can i do this with insert query? let 3,4,6 is the return column value of other table. Return column Answer Get rid of the

Advertisement