Trying to create a lookup to run an import for a file into the database, and within the query I created that would insert an address from the import file if it was not found, I am getting the Error Code 515 stating that it "cannot insert the value NULL into column 'R_Identity'; column does not allow nulls; INSERT fails."
This is the query I created:
Declare @CONSIGNEEROWID UniqueIdentifier Declare @STREET Varchar(40) Declare @CITY VarChar(30) Declare @STATE Char(5) Declare @ZIP VarChar(20) Declare @COMPANYID Char(2)
begin if not exists (Select * from idaddress where idaddress.address_1 = @street and idaddress.city = @city and idaddress.state = @state and idaddress.zip = @zip) begin insert into idaddress (idaddress.address_1, idaddress.city, idaddress.state, idaddress.zip) values (@street, @city, @state, @zip) end end Select @CONSIGNEEROWID AS CONSIGNEEROWID
I tried seemingly everything to fix the error code, but to no avail. The query is ideally for when a txt file is imported, this specific lookup in the mapping would create the address found in the file, if the lookup can not locate the address, i.e. address_1, city, state, zip, country.