I have some SQL (not written by me) and I cannot find the meaning of it.
Statement is similar to:
INSERT INTO OPENQUERY (linkedServerName, "SELECT col1, col2 FROM service WHERE ServiceId < 0")
(col1, col2)
SELECT col1, col2 FROM Service
I get the point with "insert into" part, but I cannot understand the "WHERE ServiceId < 0" clause.
What this condition introduce to INSERT (select?) statement?
In this part of the code:
INSERT INTO OPENQUERY (linkedServerName, "SELECT col1, col2 FROM service WHERE ServiceId < 0")
You detail the table and columns where you want to put the data, so the WHERE makes no sense. Maybe internally it's allowed because the engine just retrieve from there the table name and the list of columns, so it doesn't return any error.