Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 sp in query analysier..printing to console

Author  Topic 

genic
Yak Posting Veteran

57 Posts

Posted - 2001-04-20 : 11:47:35
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)
As
declare @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
END
else
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)'
END

select @sql

return


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?

   

- Advertisement -