How would this INSERT statement be rewritten without the subquery, so it no longer results in the error “Subqueries are not allowed in this context. Only scalar expressions are allowed”?
INSERT INTO FUNCTIONAL_AREA (
FUNCTIONAL_AREA_UUID
,FUNCTIONAL_CATEGORY_UUID
,CREATE_DATETIME
,CREATE_USER
,LUPDATE_DATETIME
,LUPDATE_USER
,DESCRIPTION
,ITEM_CODE
,IS_ACTIVE
) VALUES (
NEWID()
,(select functional_category_uuid from functional_category where description = 'ADLs')
,GETDATE()
,'11111111-1111-1111-1111-111111111111'
,GETDATE()
,'11111111-1111-1111-1111-111111111111'
,'Bathing - Ability'
,1081
,1)
Thank you!
EDIT Adding:
If you only want one row inserted and you care about which row is selected from functional_category, then either narrow the where clause so only one row comes back, or use an order by and top 1: