I have been suffering at this for two hours now. I want to select or insert a record. If the record exist select his ID else insert it and get the new inserted ID. For now I'm trying to run this but I still get an error
SELECT CASE WHEN (SELECT COUNT(*) FROM Domains WHERE Domain = @domain)>0
THEN
(SELECT Domain_ID FROM Domains WHERE Domain = @domain)
ELSE
INSERT INTO Domains(Domain_ID,Domain,Disabled,Description) VALUES(@Domain_ID,@Domain,@Disabled,@Description);