declare @ownerId int = ; declare @ownerType varchar(3) = ; declare @fspro_userId int = ; with data as ( select fspro_userId, ownerId, fsl_tablecode, nullif( firstName, '' ) firstName, nullif( lastName, '' ) lastName, nullif( organization, '' ) organization, nullif( address1, '' ) address1, nullif( address2, '' ) address2, nullif( city, '' ) city, nullif( state, '' ) state, nullif( zipCode, '' ) zipCode, nullif( phone, '' ) phone, nullif ( cellPhone, '' ) cellPhone, nullif( email, '' ) email, nullif( title, '' ) title, staffMember, loginEnabled from tbl_FSPro_members with (nolock) where ownerId = @ownerId and fsl_tablecode = @ownerType and fspro_userId = @fspro_userId ) #forJSON( 'data', attributes.dataStore, 'lastName' )# attributes.datastore.writeToLog( _r );