branovuk (8/6/2013)
One more issue with this specific query, which gave me headache is:- db1 has record like this:
record_id, column1, column2, column3, column4.
- db2 has record like this:
record_id, column_id (based on column value - db2 has table with column_id, column value), and value column.
So, I am inserting next:
From db1: record_id, column1 in new db2 record (or update existing) with values record_id, column_id, value.
Example (for new record):
INSERT (from db1) (record_id, column1) with values (1, Drawings)
INTO
db2 (record_id, column_ID) = 1, 123 (where 123 is column_id for Drawings).
After first, INSERT is taking second value from db1 and inserting it ...
Thanks,
Brano
You are going to have to paint a far clearer picture here if you want detailed assistance. You will need to post a few things:
1. Sample DDL in the form of CREATE TABLE statements
2. Sample data in the form of INSERT INTO statements
3. Expected results based on the sample data
Please take a few minutes and read the first article in my signature for best practices when posting questions.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/