I use in my Project the IfExistsTable function; in order to see the existence of a table.
For this purpose I use the Select statement as follows.
MASQLComm = New SqlCommand("SELECT COUNT(*) AS [RecCount] From sys.tables WHERE name Like '%" & tName & "%'", SQLConn)
RecCount = CInt(MASQLComm.ExecuteScalar)
After that I take the number which returned in RecCount. Until now the numbers was 1 and 0
And so I was turn the numbers in True or False.
Now suddenly the returned number is 2 which I can’t understand what it means.
The number represents the number of tables that match your like statement. For example, if you have the tables
And pass “Widgets” into your query, it’s going to match both the table “Widgets” and “WidgetsInProducts”. This is not the behavior you want.
To resolve this you need to do an exact match instead of a like as @Alex Aza demonstrated in his answer.