-1
I want to Insert in table A of the key field, but only if this key already exists in table B
Example Insert key(123) in table B if there is key(123) in table a
(am using sql procedures managemente studio)
ALTER procedure [dbo].[InsertHeartRate]
(
@TimeStamp datetime = '',
@Value varchar(3) = '',
@MacAddress varchar(30) = ''
)
as
BEGIN
Insert into HeartRate (TimeStamp,Value,MacAddress)
Select @MacAddress
where (Select @MacAddress
From banda
where MacAddress= @MacAddress);
Values(@TimeStamp,@Value,@MacAddress)
END
I’m trying to change the process, but with difficulties, the key would be the macaddress
This answers your question? How to Insert into the table if the record does not exist
– Ricardo Pontual
thanks, but no, I want to insert in the tebela a, but only when the key 123 ja EXIST in table b.
– Drakan x
and isn’t that what the answer shows but with a "no" exist? if you take the
not
that has in thenot exists
will not do exactly what you want?– Ricardo Pontual
yes I thought about this option, but if the value does not exist it lets insert?
– Drakan x
do a test :) also, put in your question a tag with the database you are using
– Ricardo Pontual