No, it produces the same error. I tried it with some test data that I set up and it works fine. It is failing on a particular set of data (a clients monthly db update).
Oh, duh, just found out the reason while explaining the problem. Table2 does not use an index and contained duplicates...
I should elaborate, sorry for double post, cant seem to be able to edit posts.
It was a typo in the post, that is not what is producing the error.
Thanks,
DT
ah yes, typo, should be:
INSERT INTO table 1
SELECT table2.code,
table2.name
FROM table2
WHERE NOT EXISTS (
SELECT table1.code
FROM table1
WHERE table1.name = table2.name )
Hi, I have two tables both containing data under the same column headings and types, code and name. The name column is a unique index with an insert and update constraint.
I am trying to insert data from table2 to table1 when the data does not already exist in table1 but am getting a unique key...
Yah, that would bring out results like:
col1 col2 col3 col4
4.5 2.3 6.7 2.6
I needed results like
colName average
'col1' 4.5
'col2' 2.3
'col3' 6.7
'col4' 2.6
Can be achieved with a union:
SELECT avg(col1) as average,
'col1' as colName
UNION ALL
SELECT...
Hi there, I have a table with 8 integer columns and I want to return the average value for each column in a single query.
I can do it easily enough with 8 columns but I would like the query to contain only two columns, 'columnName' and 'average'.
Is this possible?
Thanks, dom
Ok thankyou,
I am new to anything but SPs and general db design. Could you give me an example of how I might implement this (or soewhere where there is an example, can't find anything on google or here)? Would the UDF need calling to define the variable...?
DT
How can you set static variables in enterprise manager? I think 'static variables' is the correct term. Basically, I would like to do something like:
SELECT blah
FROM tableBlah
WHERE blahID = @@myStaticBlahID
Can I create and set these @@ variables in EM?
Thanks in advance
DT
Yes kinda, the client should initiate the process. I.e. it is not viable to have it on a scheduled time, it must be 'triggered' by the client's action.
Thanks,
DT
Would it be possible to trigger a DTS package? There is no definate schedule for it and there may be several updates in a month. There will be no technical person involved, the entire process must be initiated and controlled by the non techie client.
We have setup an online shop for a client and are using a SQL server database for all their stock, etc. They receive a monthly stock update from there main supplier which is stored in an access db on their pc's at their bricks and mortar shop.
I am looking to the most efficient way of updating...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.