473,396 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

execute command - urgent!!

Hi,

Please check following code.
In below code I don't want to display results of "execute (@sql)", but want @cntA to be displayed. Is there any command to stop display of execute command as per situation.


DECLARE @YEAR1 VARCHAR(10),@MONTH1 VARCHAR(10),@SQLJOINYR VARCHAR(50),@SQLJOINMN VARCHAR(50),
@CS VARCHAR(1), @SQL VARCHAR(1000),@CSTYPE VARCHAR(50),@cntA int
SET @YEAR1 = '2004'
SET @MONTH1 = '04'
SET @CS = 'P'
SET @SQLJOINYR = ' AND year(A.joining_date)= (''' + @year1 + ''')'
SET @SQLJOINMN = ' and month(A.joining_date)= (''' + @month1 + ''')'
SET @CSTYPE = ' AND B.CS_TYPE = (''' + @CS + ''') '

SET @SQL = 'select a.employee_id from UGAM_ERM..employee_master a, emp_dept b where
a.employee_id = b.emp_id '
SET @SQL = @SQL + @SQLJOINYR + @SQLJOINMN + @CSTYPE
--PRINT (@SQL)

set nocount on
execute (@sql)
set @cntA = @@rowcount

SELECT @cntA
Oct 4 '06 #1
1 2462
hey,

see if this is gonna work for you:

Expand|Select|Wrap|Line Numbers
  1. DECLARE @YEAR1 NVARCHAR(10),@MONTH1 NVARCHAR(10),@SQLJOINYR NVARCHAR(50),@SQLJOINMN NVARCHAR(50),
  2. @CS NVARCHAR(1), @SQL NVARCHAR(1000),@CSTYPE NVARCHAR(50),@cntA int
  3. SET @YEAR1 = '2004'
  4. SET @MONTH1 = '04'
  5. SET @CS = 'P'
  6. SET @SQLJOINYR = ' AND year(A.joining_date)= (''' + @year1 + ''')'
  7. SET @SQLJOINMN = ' and month(A.joining_date)= (''' + @month1 + ''')'
  8. SET @CSTYPE = ' AND B.CS_TYPE = (''' + @CS + ''') '
  9.  
  10. SET @SQL = 'select @cnt=COUNT(a.employee_id) from UGAM_ERM..employee_master a, emp_dept b where 
  11. a.employee_id = b.emp_id '
  12. SET @SQL = @SQL + @SQLJOINYR + @SQLJOINMN + @CSTYPE
  13. --PRINT (@SQL)
  14.  
  15. set nocount on
  16. EXEC sp_executesql @sql, N'@cnt INT OUTPUT', @cntA OUTPUT
  17. set @cntA = @@rowcount
  18.  
  19. SELECT @cntA
  20.  
Oct 5 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Valentine Kouznetsov | last post by:
Hi, simple question, how to execute command in current shell, not in subshell? Example. I have environment variable A=aaa and need to invoke shell (sh) script which will do something with A. If...
2
by: david Wilton | last post by:
Hi all, Does anyone know how to execute command line in ASP? thanks David
1
by: josh | last post by:
anybody know why "edit-and-execute-command" doesn't work in python's readline? it doesn't even show up in a dump of readline functions: $ cat fc_test C-p: dump-functions C-e:...
1
by: Matt | last post by:
I used to execute a command line script in IIS 4 using Dynuexec. This is a third part server object I installed on the server (http://www.dynu.com/dynuexec.asp). I installed this object onto my...
1
by: sathya | last post by:
hi, i have problem in httphandler, my problem is that when i am trying to use server.execute(/default.aspx) i am getting error.... Here i am trying to redirect from home.aspx to...
1
by: sathya | last post by:
hi, i have problem in httphandler, my problem is that when i am trying to use server.execute(/default.aspx) i am getting error.... Here i am trying to redirect from home.aspx to...
2
by: Michael | last post by:
Question. Is it possible to run Server.execute command inside global.asa file. if it is where. Inside Application onstart? Another ideas appreciated. Michael
23
by: ticfranca | last post by:
Hi, I'm getting this error in the code below: sub Pega_recorde { $database = 'bundinha'; $host = 'localhost'; $usuario = 'myhumoradm'; $senha = 'my8xr2d2'; ...
7
by: sonet | last post by:
in perl we can execute command and get result(command line stdout) by $a=`cmdline parameter`; print $a; in c system('cmdline parameter'); but i can not get the result (command line stdout).
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.