Reputation: 13
I've been trying to understand this t-sql query but I'm not sure what the 'where' clause means. Here is the query:
UPDATE s
SET s.ID1 = p.ID1,
s.FIRST_NAME = p.FIRST_NAME,
s.LAST_NAME = p.LAST_NAME,
s.DEPT_DESCR = p.DEPT_DESCR
FROM dbo.DIRECTORY_VW S
JOIN ps.STAGING_DIRECTORY_VW P ON s.ID = p.ID
WHERE p.ID <> ''
I understand the query updates ID1, FIRST_NAME, LAST_NAME, and DEPT_DESCR values on the DIRECTORY_VW view with the values from the STAGING_DIRECTORY_VW, where the ID is the same, but what does the <> ''
mean? <>
is NOT EQUAL in T-SQL but I'm having trouble finding what two single quotes do.
Thanks in advance!
Upvotes: 0
Views: 84
Reputation: 13641
''
in tsql is an empty string. It's a string that is not NULL, but also has nothing in it.
So,
someVal <> ''
is not the same as someVal IS NOT NULL
Upvotes: 2
Reputation: 25091
Two back-to-back apostrophes (''
) is a common way of representing an empty string, so the WHERE
clause is simply where p.ID
is not equal to an empty string.
Upvotes: 0