Hello,
I've the following problem:
I need to insert to a table the following customer data:
Year No., Month No., CustomerName, CustomerID... The problem is with the Month No. (MonthNo is the table column name). I'm using the following command, in a stored procedure, after the insertion.
SET @MonthNo = (SELECT COUNT (*) FROM Customers, Tools WHERE Customers.CustomerID = Tools.CustomerID AND MONTH(Tools.DeployDate) = MONTH(GETDATE()))
But it doesn't work perfectly. When it comes to the next month, it inserts zeros. How could I work this out properly?
Thank you in advance!