IF NOT EXISTS (SELECT TOP 1 CityName FROM dbo.City WHERE [Name] = 'Default City')
BEGIN
INSERT dbo.City ( CityName, Status,CityCategoryId) VALUES
(N'Default City', 0, (SELECT CityCategoryId FROM dbo.CityCategory WHERE [CityCategoryName] = N'Default City Category'))
END
GO
i have the the above query which runs fine in SQL server 2012 but fails in SQL Server 2005 with the below error message.
Subqueries are not allowed in this context. Only scalar expressions are allowed.