i am building a dynamic query based upon several cases. i have fixed most of my problems, but i am trying to test this and find out exactly whats being built and what isnt. i would like to use query analysier to test this..but it is not working. here is the query.Alter Procedure sp_selectAllocatedHours_date@date1 datetime,@date2 datetime,@profileorg varchar(255),@profiledept varchar(255),@profileteam varchar(255)Asdeclare @sql varchar(512)if (@profileorg <> '') BEGIN set @sql = 'select sum(convert(decimal(10,4), b.hours)) as totalTime from profile as a inner join projecttime as b on (b.profileemail = a.profileemail)' if (@date1 <> '') or (@date2 <> '') BEGIN set @sql = @sql+ 'where b.workdate between @date1 and @date2 and' END if (@profileorg <> '1') AND (@date1 = '') or (@date2 = '') BEGIN set @sql = @sql + ' WHERE a.profile_org = @profileorg' END if (@profileorg <> '') AND (@date1 <> '') or (@date2 <> '') BEGIN set @sql = @sql + ' AND a.profile_org = @profileorg' END if (@profileorg = '1') AND (@profiledept ='1') BEGIN set @sql = @sql + ' and a.profile_dept = @profiledept' END if (@profileorg = '1') AND (@profiledept ='1') AND (@profileteam ='1_1') BEGIN set @sql = @sql + ' and a.profile_team = @profileteam' END ENDelse BEGIN set @sql = 'select sum(convert(decimal(10,4), b.hours)) as totalTime from profile as a inner join projecttime as b on (b.profileemail = a.profileemail)' ENDselect @sqlreturn
all that is returned is command ran successfully. i would like to return what was built within @sql. print @sql does not work....am i just stupid?