O R G A N I C / F E R T I L I Z E R: ssrs: the variable name has already been declared -- when working with temp tables

Sep 29, 2010

ssrs: the variable name has already been declared -- when working with temp tables

here is today's hair pulling exercise.  I created a very simple sql query (the one I was using too complex to see the problem clearly).  note below:

   1: declare @Marcus table
   2:     (
   3:         resourceid nvarchar(10),
   4:         name nvarchar(255)
   5:     )
   6:  
   7: insert into @marcus
   8: select resourceid,name0 from v_r_system
   9:  
  10: select * from @marcus

 

when executed in sql server management studio, the query runs as expected.  it just grabs resourceid and system name, puts them into a temporary table, and draws them right back out.  however, when executed in bids (business intelligence development studio), you receive the error stating "the variable name has already been declared. variable names must be unique within a query batch or stored procedure."

image

 

right thanks. so after much chasing geese wildly, I discovered that while windows is decidedly case insensitive, sometimes it changes its mind.  in visual studio (bids, etc) it appears that the case used for variables with respect to temporary tables is sensitive!

so, back to the simple query, here's the revised change.  just keep your case the same.

   1: declare @Marcus table
   2:     (
   3:         resourceid nvarchar(10),
   4:         name nvarchar(255)
   5:     )
   6:  
   7: insert into @Marcus
   8: select resourceid,name0 from v_r_system
   9:  
  10: select * from @Marcus