View Complete Post
I have 2 tables:
- Salesmen with Pk.SalesmenID
- Appointments with Fk.SalesmenID and busy(bit)
How can I check if every salesmen has at least one appointment
Am I on the right way with statement below, though I got syntax problems
(SELECT COUNT(distinct SalesmanID)FROM Appointments)
(SELECT COUNT(SalesmanID) FROM Salesmen)
heys all i was wondering if we do if not exists(select*from information_schema.tables where table_type='base table' and table_name='tbl')
is it slower than if not exists(select 1 from information_schema.tables where table_type='base table' and table_name='tbl')
because we select less things in the inner query?
Let's say I have a table like this:
When I insert, I want:
if(not exists(select 1 from MyTable where Data = @MyXMLString))
insert into MyTable(Data) values(@MyXMLString)
The problem is, Data = @MyXMLString does not work because Data is XML, @MyXMLString is varchar. So, how should I do this?