how to create trigger in SQL server using two tables to find stock quantity
Instead of creating a trigger I would suggest you to create a new column in the purchase table which will be a computed column.

Before creating it, create a scalar function which will accept productname or productid and returns int. Inside it, write a query to find the total from sales for that particular row (by passing productname or id) and subtract it from purchase's quantity for that product.

If purchase can contain multiple entries for a particular product then create a separate table Stock and have columns as ID, ProductName\Id, stockQuantity (which will be a computed column as explained above).