title: how to get current month in T-SQL sql server(2008)
body: <pre><code>CREATE TABLE _Transaction (
  transaction_id int,
  date_time datetime default sysdatetime(),
  amount real,
  description varchar(500),
  responsible_party varchar(50),
  
  CONSTRAINT _transaction_pk PRIMARY KEY(transaction_id),
  CONSTRAINT check_res_prty CHECK(responsible_party IN ('[ATM]','[Teller]','[Bank]','[Standing Order]','[Cheque]','[On-Line]','[Other]'))
   );
  
  CREATE TABLE _Transaction_account(
  account_no int,
  transaction_id int,
  affect_type varchar(50),
  
  CONSTRAINT _Transaction_account_pk PRIMARY KEY(account_no,transaction_id),
  CONSTRAINT _Transaction_account_fk1 FOREIGN KEY(transaction_id) REFERENCES _transaction(transaction_id),
  CONSTRAINT _Transaction_account_fk2 FOREIGN KEY(account_no) REFERENCES account(account_no),
  CONSTRAINT check_affect_type CHECK(affect_type IN ('[credit]','[debit]'))
  );
  </code></pre>
  
  <p>I want to write a stored procedure to above tables which takes the account number and returns the number of cheques processed for that account during the current month. so I wrote the below stored procedure</p>
  
  <pre><code>CREATE PROCEDURE pro_check_cheques (@accountNo int)
  AS
  BEGIN
      DECLARE @chques int
      SELECT @chques=COUNT(t.responsible_party)
      FROM _Transaction t JOIN _Transaction_account ta ON
          ta.account_no=@accountNo AND ta.transaction_id=t.transaction_id
      WHERE t.responsible_party = '[Cheque]' AND t.date_time=MONTH(GETDATE())
      print  @chques;
  END
  </code></pre>
  
  <p>but this is not works. always get the 0 counts when I execute the sproc, but when I delete the part that "AND t.date_time=MONTH(GETDATE())" is, it works fine. 
  please can anyone help me?
  thanks</p>