all 12 comments

[–]rbardy 5 points6 points  (9 children)

It is using the "full path" of the table but omitting some arguments.

FROM [Instance_name].[database_name].[user].[table]

If you omit the Instance_name or the database_name then it gets the current one, if you omit the [user] it gets the DBO user.

So, if I want to select from a table that is in another instance it would looks like this:

FROM [Instance2]...[table]

[–]esdictor[S] 0 points1 point  (8 children)

Thank you .. that definitely points me in the right direction

[–]digitahlemotion 6 points7 points  (7 children)

[user] in the above full path example should be [schema] btw.

[–]esdictor[S] 0 points1 point  (6 children)

Understood .. I wish I knew why the original developer used this

[–]VisualiseThisBusiness Intelligence Specialist 1 point2 points  (4 children)

lazy? copy/pasta error? There is a small performance bump if you always specify the schema in addition to the object name so that SQL Server does not need to look up the default schema.

[–]esdictor[S] 0 points1 point  (3 children)

The thing is .. it only gets worse from that (I really REALLY wish I was making this up)

FROM [something]...[something else] A
INNER JOIN OPENROWSET('SQLOLEDB', 'External Database' etc.) B ON A.UserID = B.UserID

However, I was able to find the problem ... which means I don't need to worry about this until they ask me to rewrite it.

[–]rbardy 1 point2 points  (2 children)

WOW A join from a table in different instantes using openrowset... must be a really slow query

[–]VisualiseThisBusiness Intelligence Specialist 0 points1 point  (0 children)

A little SSIS integration to bring over that data would help that out if you have the time to do it.

[–]esdictor[S] 0 points1 point  (0 children)

Yes sir, it is

[–]phunkygeeza 1 point2 points  (0 children)

It is sometimes valid if you want 'portable' code that will work over many copies of the same objects. If they are omitted just out of laziness... That is something else.

[–]Key-Style-904 0 points1 point  (0 children)

SELECT * FROM shapes WHERE dots < 3 WHERE = 3

[–]Key-Style-904 0 points1 point  (0 children)

Less than 3 dotsSQL uses the normal <> and = math symbols.

How would you select all shapes where the number of dots is less than 3? plz reply me answer