473,666 Members | 2,053 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Converting Traceid issue

Hi,

I am trying to automate a SQL Trace via a stored procedure and a job. The job
executes the stored procedure to start the trace and every 15 minutes, the
job is supposed to stop the trace, clear it from memory, rename the trace
file, and start a new trace so I can select the average duration for this
process. I am getting the following error message:

Procedure expects parameter '@traceid' of type 'int'

When I try to run this portion of the script (@traceid is declared as an INT
at the beginning of the job):

Set @traceid = (select distinct(conver t(int,traceid)) from ::fn_trace_geti nfo
(default) where value = 'D:\MSSQL\JOBS\ HCMDB_RequestQu eue_Trace.trc') -- the
name of my trace file

print 'Stop current trace'
exec sp_trace_setsta tus @traceid,0

print 'Erase current trace from memory'
exec sp_trace_setsta tus @traceid,2

print 'Moving file to _1'
exec master..xp_cmds hell 'move D:\MSSQL\JOBS\H CMDB RequestQueue Trace.trc D:\
MSSQL\JOBS\HCMD B_RequestQueue_ Trace1.trc',
NO_OUTPUT

I know I must be missing something obvious, but I haven't been able to figure
it out. Any assistance is greatly appreciated.

Thanks,
Michael

--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums...neral/200602/1
Feb 28 '06 #1
3 2432
michael via SQLMonster.com (u13012@uwe) writes:
I am trying to automate a SQL Trace via a stored procedure and a job.
The job executes the stored procedure to start the trace and every 15
minutes, the job is supposed to stop the trace, clear it from memory,
rename the trace file, and start a new trace so I can select the average
duration for this process. I am getting the following error message:

Procedure expects parameter '@traceid' of type 'int'

When I try to run this portion of the script (@traceid is declared as an
INT at the beginning of the job):

Set @traceid = (select distinct(conver t(int,traceid)) from
::fn_trace_geti nfo> (default) where value =
'D:\MSSQL\JOBS\ HCMDB_RequestQu eue_Trace.trc') -- the
name of my trace file

print 'Stop current trace'
exec sp_trace_setsta tus @traceid,0
...
I know I must be missing something obvious, but I haven't been able to
figure it out. Any assistance is greatly appreciated.


Obvious and obvious... First a hint. Try this:

DECLARE @traceid int
exec sp_trace_setsta tus @traceid,0

This give the same error as you get. sp_trace_setsta tus does not
like the NULL value.

So presumably, you fail to set @traceid. The value column of
fn_get_tracesta tus is sql_variant. Per the conversion rules in
SQL Server, the string literal is converted to sql_variant. I believe
that for to sql_variant values to be equal, they must have the same
base type. But value for the file name, is surely nvarchar.

So adding an N before string literal to make it nvarchar may work.
I would recommand to explicitly convert value to nvarchar(4000).
is sql_variaamt

--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Feb 28 '06 #2
Thanks for your response. I think I might not have stated the issue clearly
or am not understanding your response. My issue is that the traceid is not
being returned as an INT. There is no problem with the file name and the
nvarchar.

Of the PRINT statements in my code below, I get everything up to and
including 'Stop current trace'. My SET does return the traceid, but not in
integer format.

I'll do further research on the sql_variant though and see if I can get
further with that.

Thanks

Erland Sommarskog wrote:
I am trying to automate a SQL Trace via a stored procedure and a job.
The job executes the stored procedure to start the trace and every 15

[quoted text clipped - 17 lines]
I know I must be missing something obvious, but I haven't been able to
figure it out. Any assistance is greatly appreciated.


Obvious and obvious... First a hint. Try this:

DECLARE @traceid int
exec sp_trace_setsta tus @traceid,0

This give the same error as you get. sp_trace_setsta tus does not
like the NULL value.

So presumably, you fail to set @traceid. The value column of
fn_get_tracest atus is sql_variant. Per the conversion rules in
SQL Server, the string literal is converted to sql_variant. I believe
that for to sql_variant values to be equal, they must have the same
base type. But value for the file name, is surely nvarchar.

So adding an N before string literal to make it nvarchar may work.
I would recommand to explicitly convert value to nvarchar(4000).
is sql_variaamt


--
Message posted via http://www.sqlmonster.com
Mar 1 '06 #3
Okay, looks like I've got it working now. I needed to use CAST instead of
CONVERT for the traceid to get it to read as an INT.

Thanks again for the feedback.

michael wrote:
Thanks for your response. I think I might not have stated the issue clearly
or am not understanding your response. My issue is that the traceid is not
being returned as an INT. There is no problem with the file name and the
nvarchar.

Of the PRINT statements in my code below, I get everything up to and
including 'Stop current trace'. My SET does return the traceid, but not in
integer format.

I'll do further research on the sql_variant though and see if I can get
further with that.

Thanks
I am trying to automate a SQL Trace via a stored procedure and a job.
The job executes the stored procedure to start the trace and every 15

[quoted text clipped - 19 lines]
I would recommand to explicitly convert value to nvarchar(4000).
is sql_variaamt


--
Message posted via http://www.sqlmonster.com
Mar 1 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
16459
by: Joseph Suprenant | last post by:
I have an array of unsigned chars and i would like them converted to an array of ints. What is the best way to do this? Using RedHat 7.3 on an Intel Pentium 4 machine. Having trouble here, hope someone can help Thanks
2
7668
by: Mariusz Sakowski | last post by:
I'm writing class which will be able to store large numbers (my ambition is to make it able to operand on thousands of bits) and perform various operations on it (similiar to those available with int type). I want to store the number as binary stream, and I don't know how to convert large decimal string (char*) to binary stream. Converting using MOD would last for hours with really big numbers, and in fact I don't know any other ways to...
1
3379
by: William F. Zachmann | last post by:
I am working on a project converting a DLL originally written in C++ using Visual Studio 97 accessing a SQL 6.5 data base to VS.Net 2003 and SQL Server 2000. I would very much appreciate any suggestions and/or references to good sources for information about issues I am likely to encounter along the way. My immediate issue, however, is that after opening the old project and accepting the conversion to VS2003, a build fails with five...
2
1583
by: genc_ymeri | last post by:
Hi, Well, I'm looking around for another opinion. We have two webservers, the legacy one writen in ASP and the new one in ASP.Net. Once a user logs in the ASP.Net web app, the session of the Login page gets stored in a DB (in a binary format). Meantime, if the user chooses to go and run the web legacy system, he doesn't want to log in again, so an "option" we are considering is to go and get the data from session of Login Page (of...
1
1795
by: darrel | last post by:
I have two issues: 1) The WYSIWYG content editor we're using for our CMS doesn't truly support xhtml. 2) .net doesn't truly support xhtml my question is if there is a .net library/class/component that can convert from html to xhtml?
5
2514
by: Robert | last post by:
I have a series of web applications (configured as separate applications) on a server. There is a main application at the root and then several virtual directories that are independant applications. I am testing an upgrade of all of the sites and have converted the main root site...although not necessarily fixed any issues. I move on instead and converted one of the virtual roots that is a seperate
3
6093
by: Sharon | last post by:
I have a buffer of byte that contains a raw data of a 1 byte-per-pixel image data. I need to convert this buffer to a Bitmap of Format32bppArgb and to a Bitmap of Format24bppRgb. Can anybody tell how to do it? ------ Thanks
15
9653
by: allthecoolkidshaveone | last post by:
I want to convert a string representation of a number ("1234") to an int, with overflow and underflow checking. Essentially, I'm looking for a strtol() that converts int instead of long. The problem with strtol() is that a number that fits into a long might be too big for an int. sscanf() doesn't seem to do the over/underflow checking. atoi(), of course, doesn't do any checking. I've long thought it odd that there aren't strtoi() and...
10
3234
by: Hank Stalica | last post by:
I'm having this weird problem where my code does the following conversion from string to float: 27000000.0 -27000000.00 2973999.99 -29740000.00 2989999.13 -2989999.25 The number on the left is the string I get after tokenizing a bigger string. The number on the right is the number I get after the conversion.
0
8444
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8781
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8639
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7386
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4368
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2771
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1775
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.