Hi,
how much ohm should resistor 2 be?.....i tried 500 - 1000 ohm but i didn't work
If the transistor is OK, then you probably have wired something wrong or shunted something.
Assuming 12V on the relay the collector current amounts to 12/400 = 30mA
The transistor will have a gain of at least 100, so the base current should be 30m/100 = 300µA
Assuming the digital pin is 5V logic, the base resistor should then be (5-0.7)/300µ = 14.3 kOhm
Selecting
10k you have a bit of overhead (which you need due to the other resistor).
Anything lower should work as well, as long as it doesn't get low enough to load the pin down - you can get the output capability in the datasheet for the mysterious "digital device" having the pin.
1kOhm should work, else go upwards towards 10kOhm (don't go lower).