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
 General SQL Server Forums
 New to SQL Server Programming
 how 2 fetch result of a qry whn exeuted using exec

Author  Topic 

Jabez
Starting Member

19 Posts

Posted - 2007-07-14 : 10:06:51
Hi Folks,

declare @strDBName as varchar(100)
set @strDBName = 'MYHRMIS_WEBEX'
declare @EmpCode as varchar(50)
set @EmpCode = '60874'
declare @SQL as varchar(8000)
set @SQL = ' select count(*) from ' + @strDBName + '.dbo.Reqrec_EmployeeDetails where ed_empcode = ''' + @EmpCode + ''' and ed_status in (1, 4) '
print @SQL
exec(@SQL)

How do I get the result of this query into a variable.
Thanks in advance.

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-07-14 : 10:37:30
Refer this
http://www.nigelrivett.net/SQLTsql/sp_executesql.html


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Jabez
Starting Member

19 Posts

Posted - 2007-07-16 : 04:15:20
Thanks.
Go to Top of Page
   

- Advertisement -