Hi,
I have a stored proc that has one output parameter. When I call
this sp from my client program (an MS Access VBA) it has always worked fine,
but just recently started to give me a message saying that the stored
procedure is expecting a parameter named @.TPRD but did not receive it,
program fails. @.TPRD is the output parameter and is declared as such. I
have not changed the sp recently so there is no code change in the sp. I
do not administrate my SQL Server, but I did request my administrator to
grant me EXEC access to sp_debug so that I could run the stored procedure
debugger. My sp stopped working at about the same time. Do you think
these two events could be related? How to solve? The code for my
stored procedure is below:
ALTER PROCEDURE [ad\jmuseck].[SELECT_TPRD]
@.TPRD VARCHAR(6) OUTPUT
AS
SELECT @.TPRD = TPRD
FROM tblCurrentMonth
RETURN @.TPRD
----
The code in my client MS Access VBA program looks like this:
Function SelectTprd(Optional newval As Variant) As String
Dim cmdCommand As ADODB.Command
Dim prmTPRD As ADODB.Parameter
Set cmdCommand = New ADODB.Command
cmdCommand.ActiveConnection = CurrentProject.AccessConnection
cmdCommand.CommandType = adCmdStoredProc
cmdCommand.CommandText = "SELECT_TPRD"
cmdCommand.Parameters.Refresh
<--STARTED FAILING ON THIS LINE !!
Set prmTPRD = cmdCommand.CreateParameter("@.TPRD", adChar, adParamOutput)
cmdCommand.Execute
'Return the time period to the calling program.'
SelectTprd = cmdCommand.Parameters(1).Value
Set cmdCommand = Nothing 'Free memory
End FunctionHello, Joe
This problem is related to MS Access, more specifically to the OLEDB
provider that Access uses internally. Use one of the following
workarounds:
1. Do not use Parameters.Refresh; instead of this, add each of the
parameters of the stored procedure (even if they have default values)
to the Parameters collection, *in the same order that they are
defined*, using something like this:
cmd.Parameters.Append cmd.CreateParameter("@.ParameterName",...)
2. Use another connection, based on the SQL Server OLEDB provider
(instead of the internal Access OLEDB provider), i.e. instead of the
line:
cmdCommand.ActiveConnection = CurrentProject.AccessConnection
use the following:
cmdCommand.ActiveConnection = CurrentProject.BaseConnectionString
3. If you use at least ADO 2.6, set the NamedParameters property to
True (before setting the ActiveConnection property) and:
a) use Parameters.Refresh (after setting the ActiveConnection) and fill
only the input parameters you need with something like this:
cmd.Parameters("@.ParameterName")=Value
after cmd.Execute, you can get the value of the output parameter by
reffering to it the same way:
Variable=cmd.Parameters("@.ParameterName")
or:
b) do not use Parameters.Refresh, but add the input parameters that you
need (in any order) (it's not necessary to add the input parameters
that have default values) , and also the output parameters (before
setting the ActiveConnection), with something like this:
cmd.Parameters.Append cmd.CreateParameter("@.ParameterName",...)
after cmd.Execute, you can get the value of the output parameter by
reffering to it the same way as above:
Variable=cmd.Parameters("@.ParameterName")
For more informations about the last method, see:
http://msdn.microsoft.com/library/e...dparameters.asp
The easiest method would be the second one (using the
BaseConnectionString to open another connection).
Note: in this message, I wrote about the case when the procedure has
more input parameters, some of them having default values, in addition
to the output parameters. In your case, if you have just one (output)
parameter, some of my remarks do not apply (i.e. adding the parameters
in the same order that they are defined, etc).
Razvan
Showing posts with label parameters. Show all posts
Showing posts with label parameters. Show all posts
Friday, March 9, 2012
Expect Parameters which was not supplied when hit the preview tab
I'm creating my reports and connect to the stored procedure. The results of
data returned when I'm on Data Tab. However when I hit the Preview Tab I got
the error said "An error has occured during report processing. Query
execution failed for data set "TheNameOfMyData". Procedure
"MyWebProcedureName" expect parameters "@.Blah_1" which was not supplied".
What was wrong with the errors? Do I have to pass the parameters. If
so...how do I pass the parameters? Help would much appreciate.One of two things has happened. Either you do not have report parameters or
you have report parameters and the query parameters are not mapped to the
report parameter. Usually, but not always, RS creates the report parameter
automatically for you.
In the data tab click on the ..., go to parameters tab. It should like all
your query parameters and what report parameter it maps to. If empty then go
to layout, click somewhere on blank part of the report. go to the menu
report->parameters. You need to have a report parameter per query parameter
(or rather you should have the report parameters you want to map to the
query parameters to be listed). If not there then add them. Then go back to
the data tab, click on the ... and map the query parameters to the report
parameters.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"MissQti" <MissQti@.discussions.microsoft.com> wrote in message
news:2F93E890-EB2E-4346-A9CF-6A8DA5E49AF3@.microsoft.com...
> I'm creating my reports and connect to the stored procedure. The results
> of
> data returned when I'm on Data Tab. However when I hit the Preview Tab I
> got
> the error said "An error has occured during report processing. Query
> execution failed for data set "TheNameOfMyData". Procedure
> "MyWebProcedureName" expect parameters "@.Blah_1" which was not supplied".
> What was wrong with the errors? Do I have to pass the parameters. If
> so...how do I pass the parameters? Help would much appreciate.|||BIG THANKS to Bruce for the help. It worked when I mapped the report
parameter to query parameters.
"Bruce L-C [MVP]" wrote:
> One of two things has happened. Either you do not have report parameters or
> you have report parameters and the query parameters are not mapped to the
> report parameter. Usually, but not always, RS creates the report parameter
> automatically for you.
> In the data tab click on the ..., go to parameters tab. It should like all
> your query parameters and what report parameter it maps to. If empty then go
> to layout, click somewhere on blank part of the report. go to the menu
> report->parameters. You need to have a report parameter per query parameter
> (or rather you should have the report parameters you want to map to the
> query parameters to be listed). If not there then add them. Then go back to
> the data tab, click on the ... and map the query parameters to the report
> parameters.
>
> --
> Bruce Loehle-Conger
> MVP SQL Server Reporting Services
> "MissQti" <MissQti@.discussions.microsoft.com> wrote in message
> news:2F93E890-EB2E-4346-A9CF-6A8DA5E49AF3@.microsoft.com...
> > I'm creating my reports and connect to the stored procedure. The results
> > of
> > data returned when I'm on Data Tab. However when I hit the Preview Tab I
> > got
> > the error said "An error has occured during report processing. Query
> > execution failed for data set "TheNameOfMyData". Procedure
> > "MyWebProcedureName" expect parameters "@.Blah_1" which was not supplied".
> >
> > What was wrong with the errors? Do I have to pass the parameters. If
> > so...how do I pass the parameters? Help would much appreciate.
>
>
data returned when I'm on Data Tab. However when I hit the Preview Tab I got
the error said "An error has occured during report processing. Query
execution failed for data set "TheNameOfMyData". Procedure
"MyWebProcedureName" expect parameters "@.Blah_1" which was not supplied".
What was wrong with the errors? Do I have to pass the parameters. If
so...how do I pass the parameters? Help would much appreciate.One of two things has happened. Either you do not have report parameters or
you have report parameters and the query parameters are not mapped to the
report parameter. Usually, but not always, RS creates the report parameter
automatically for you.
In the data tab click on the ..., go to parameters tab. It should like all
your query parameters and what report parameter it maps to. If empty then go
to layout, click somewhere on blank part of the report. go to the menu
report->parameters. You need to have a report parameter per query parameter
(or rather you should have the report parameters you want to map to the
query parameters to be listed). If not there then add them. Then go back to
the data tab, click on the ... and map the query parameters to the report
parameters.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"MissQti" <MissQti@.discussions.microsoft.com> wrote in message
news:2F93E890-EB2E-4346-A9CF-6A8DA5E49AF3@.microsoft.com...
> I'm creating my reports and connect to the stored procedure. The results
> of
> data returned when I'm on Data Tab. However when I hit the Preview Tab I
> got
> the error said "An error has occured during report processing. Query
> execution failed for data set "TheNameOfMyData". Procedure
> "MyWebProcedureName" expect parameters "@.Blah_1" which was not supplied".
> What was wrong with the errors? Do I have to pass the parameters. If
> so...how do I pass the parameters? Help would much appreciate.|||BIG THANKS to Bruce for the help. It worked when I mapped the report
parameter to query parameters.
"Bruce L-C [MVP]" wrote:
> One of two things has happened. Either you do not have report parameters or
> you have report parameters and the query parameters are not mapped to the
> report parameter. Usually, but not always, RS creates the report parameter
> automatically for you.
> In the data tab click on the ..., go to parameters tab. It should like all
> your query parameters and what report parameter it maps to. If empty then go
> to layout, click somewhere on blank part of the report. go to the menu
> report->parameters. You need to have a report parameter per query parameter
> (or rather you should have the report parameters you want to map to the
> query parameters to be listed). If not there then add them. Then go back to
> the data tab, click on the ... and map the query parameters to the report
> parameters.
>
> --
> Bruce Loehle-Conger
> MVP SQL Server Reporting Services
> "MissQti" <MissQti@.discussions.microsoft.com> wrote in message
> news:2F93E890-EB2E-4346-A9CF-6A8DA5E49AF3@.microsoft.com...
> > I'm creating my reports and connect to the stored procedure. The results
> > of
> > data returned when I'm on Data Tab. However when I hit the Preview Tab I
> > got
> > the error said "An error has occured during report processing. Query
> > execution failed for data set "TheNameOfMyData". Procedure
> > "MyWebProcedureName" expect parameters "@.Blah_1" which was not supplied".
> >
> > What was wrong with the errors? Do I have to pass the parameters. If
> > so...how do I pass the parameters? Help would much appreciate.
>
>
Wednesday, March 7, 2012
Expanding sp_executesql Parameters?
Hi,
Is it possible, when using sp_executesql, to see the SQL statement with the
parameters expanded?
I'm losing years of life trying to get the following dynamic SQL statement t
o work:
DECLARE @.sSQL NVARCHAR(1000)
DECLARE @.PropStreet1 VARCHAR(50)
SET @.PropStreet1 = '0-14115 Ironwood Dr'
SET @.sSQL = N'SELECT OrderNo, PropStreet1
FROM tbl_Orders
AND CONTAINS(PropStreet1, '' " + @.PropStreet1 " '')'
SET @.Params = N' @.AddressStreet VARCHAR(50)'
EXEC sp_executesql @.sSQL, @.Params, @.AddressStreet1 = @.PropStreet1
I don't get a syntax error; but I don't get a result set either. Whereas I d
o get a result set if I just run the plain-Jane Select query (w/o using sp_e
xecutesql).
Is there a way, in Profiler for example, that I could see how SQL Server exp
ands the parameter? That I could see the final SQL statement?
Thank you.
--
--
Mark HolahanI think I see what you're trying to do here, but just to be sure, can you po
st the exact "plain-Jane SQL query" you are running?
Thx,
Mike C
"Mark Holahan" <mark.holahan@.unifiedllc.com> wrote in message news:u7wQg5nHF
HA.3500@.TK2MSFTNGP14.phx.gbl...
Hi,
Is it possible, when using sp_executesql, to see the SQL statement with the
parameters expanded?
I'm losing years of life trying to get the following dynamic SQL statement t
o work:
DECLARE @.sSQL NVARCHAR(1000)
DECLARE @.PropStreet1 VARCHAR(50)
SET @.PropStreet1 = '0-14115 Ironwood Dr'
SET @.sSQL = N'SELECT OrderNo, PropStreet1
FROM tbl_Orders
AND CONTAINS(PropStreet1, '' " + @.PropStreet1 " '')'
SET @.Params = N' @.AddressStreet VARCHAR(50)'
EXEC sp_executesql @.sSQL, @.Params, @.AddressStreet1 = @.PropStreet1
I don't get a syntax error; but I don't get a result set either. Whereas I d
o get a result set if I just run the plain-Jane Select query (w/o using sp_e
xecutesql).
Is there a way, in Profiler for example, that I could see how SQL Server exp
ands the parameter? That I could see the final SQL statement?
Thank you.
--
--
Mark Holahan|||Mike,
Plain Jane:
SELECT OrderNo, PropStreet1
FROM tbl_Orders
WHERE CONTAINS(PropStreet1, ' "0-14115 Ironwood Dr" ')
I see that I left out the word "WHERE" below; this was an oversight.
Thanks.
"Michael C#" <xyz@.yomomma.com> wrote in message news:uOIjvKpHFHA.3484@.TK2MSF
TNGP12.phx.gbl...
I think I see what you're trying to do here, but just to be sure, can you po
st the exact "plain-Jane SQL query" you are running?
Thx,
Mike C
"Mark Holahan" <mark.holahan@.unifiedllc.com> wrote in message news:u7wQg5nHF
HA.3500@.TK2MSFTNGP14.phx.gbl...
Hi,
Is it possible, when using sp_executesql, to see the SQL statement with the
parameters expanded?
I'm losing years of life trying to get the following dynamic SQL statement t
o work:
DECLARE @.sSQL NVARCHAR(1000)
DECLARE @.PropStreet1 VARCHAR(50)
SET @.PropStreet1 = '0-14115 Ironwood Dr'
SET @.sSQL = N'SELECT OrderNo, PropStreet1
FROM tbl_Orders
AND CONTAINS(PropStreet1, '' " + @.PropStreet1 " '')'
SET @.Params = N' @.AddressStreet VARCHAR(50)'
EXEC sp_executesql @.sSQL, @.Params, @.AddressStreet1 = @.PropStreet1
I don't get a syntax error; but I don't get a result set either. Whereas I d
o get a result set if I just run the plain-Jane Select query (w/o using sp_e
xecutesql).
Is there a way, in Profiler for example, that I could see how SQL Server exp
ands the parameter? That I could see the final SQL statement?
Thank you.
--
--
Mark Holahan|||I'm having a little trouble installing Full-Text Search on my beat-up little
lap-top over here. So with the caveat that I haven't actually tested it, y
ou might try the following:
DECLARE @.Params NVARCHAR(50)
DECLARE @.sSQL NVARCHAR(1000)
DECLARE @.PropStreet1 VARCHAR(50)
SET @.PropStreet1 = '0-14115 Ironwood Dr'
-- changed the parameter in your query from @.PropStreet1 to @.AddressStreet1
and got rid of the + sign
SET @.sSQL = N'SELECT OrderNo, PropStreet1 FROM tbl_Orders WHERE CONTAINS(Pro
pStreet1, '' " @.AddressStreet1 " '')'
-- changed @.AddressStreet to @.AddressStreet1
SET @.Params = N' @.AddressStreet1 VARCHAR(50)'
EXEC sp_executesql @.sSQL, @.Params, @.AddressStreet1 = @.PropStreet1
I'll see if I can clean this little box up enough to get Full-Text Search in
stalled (it really needs to be re-formatted... ah well...)
Thx
Mike C.
"Mark Holahan" <mark.holahan@.unifiedllc.com> wrote in message news:uruEiRpHF
HA.720@.TK2MSFTNGP10.phx.gbl...
Mike,
Plain Jane:
SELECT OrderNo, PropStreet1
FROM tbl_Orders
WHERE CONTAINS(PropStreet1, ' "0-14115 Ironwood Dr" ')
I see that I left out the word "WHERE" below; this was an oversight.
Thanks.
"Michael C#" <xyz@.yomomma.com> wrote in message news:uOIjvKpHFHA.3484@.TK2MSF
TNGP12.phx.gbl...
I think I see what you're trying to do here, but just to be sure, can you po
st the exact "plain-Jane SQL query" you are running?
Thx,
Mike C
"Mark Holahan" <mark.holahan@.unifiedllc.com> wrote in message news:u7wQg5nHF
HA.3500@.TK2MSFTNGP14.phx.gbl...
Hi,
Is it possible, when using sp_executesql, to see the SQL statement with the
parameters expanded?
I'm losing years of life trying to get the following dynamic SQL statement t
o work:
DECLARE @.sSQL NVARCHAR(1000)
DECLARE @.PropStreet1 VARCHAR(50)
SET @.PropStreet1 = '0-14115 Ironwood Dr'
SET @.sSQL = N'SELECT OrderNo, PropStreet1
FROM tbl_Orders
AND CONTAINS(PropStreet1, '' " + @.PropStreet1 " '')'
SET @.Params = N' @.AddressStreet VARCHAR(50)'
EXEC sp_executesql @.sSQL, @.Params, @.AddressStreet1 = @.PropStreet1
I don't get a syntax error; but I don't get a result set either. Whereas I d
o get a result set if I just run the plain-Jane Select query (w/o using sp_e
xecutesql).
Is there a way, in Profiler for example, that I could see how SQL Server exp
ands the parameter? That I could see the final SQL statement?
Thank you.
--
--
Mark Holahan|||Mike,
Thanks for your time. I'm going to post the question a little differently.
Mark
"Michael C#" <xyz@.yomomma.com> wrote in message news:ufFBc8pHFHA.4004@.TK2MSF
TNGP10.phx.gbl...
I'm having a little trouble installing Full-Text Search on my beat-up little
lap-top over here. So with the caveat that I haven't actually tested it, y
ou might try the following:
DECLARE @.Params NVARCHAR(50)
DECLARE @.sSQL NVARCHAR(1000)
DECLARE @.PropStreet1 VARCHAR(50)
SET @.PropStreet1 = '0-14115 Ironwood Dr'
-- changed the parameter in your query from @.PropStreet1 to @.AddressStreet1
and got rid of the + sign
SET @.sSQL = N'SELECT OrderNo, PropStreet1 FROM tbl_Orders WHERE CONTAINS(Pro
pStreet1, '' " @.AddressStreet1 " '')'
-- changed @.AddressStreet to @.AddressStreet1
SET @.Params = N' @.AddressStreet1 VARCHAR(50)'
EXEC sp_executesql @.sSQL, @.Params, @.AddressStreet1 = @.PropStreet1
I'll see if I can clean this little box up enough to get Full-Text Search in
stalled (it really needs to be re-formatted... ah well...)
Thx
Mike C.
"Mark Holahan" <mark.holahan@.unifiedllc.com> wrote in message news:uruEiRpHF
HA.720@.TK2MSFTNGP10.phx.gbl...
Mike,
Plain Jane:
SELECT OrderNo, PropStreet1
FROM tbl_Orders
WHERE CONTAINS(PropStreet1, ' "0-14115 Ironwood Dr" ')
I see that I left out the word "WHERE" below; this was an oversight.
Thanks.
"Michael C#" <xyz@.yomomma.com> wrote in message news:uOIjvKpHFHA.3484@.TK2MSF
TNGP12.phx.gbl...
I think I see what you're trying to do here, but just to be sure, can you po
st the exact "plain-Jane SQL query" you are running?
Thx,
Mike C
"Mark Holahan" <mark.holahan@.unifiedllc.com> wrote in message news:u7wQg5nHF
HA.3500@.TK2MSFTNGP14.phx.gbl...
Hi,
Is it possible, when using sp_executesql, to see the SQL statement with the
parameters expanded?
I'm losing years of life trying to get the following dynamic SQL statement t
o work:
DECLARE @.sSQL NVARCHAR(1000)
DECLARE @.PropStreet1 VARCHAR(50)
SET @.PropStreet1 = '0-14115 Ironwood Dr'
SET @.sSQL = N'SELECT OrderNo, PropStreet1
FROM tbl_Orders
AND CONTAINS(PropStreet1, '' " + @.PropStreet1 " '')'
SET @.Params = N' @.AddressStreet VARCHAR(50)'
EXEC sp_executesql @.sSQL, @.Params, @.AddressStreet1 = @.PropStreet1
I don't get a syntax error; but I don't get a result set either. Whereas I d
o get a result set if I just run the plain-Jane Select query (w/o using sp_e
xecutesql).
Is there a way, in Profiler for example, that I could see how SQL Server exp
ands the parameter? That I could see the final SQL statement?
Thank you.
--
--
Mark Holahan|||No prob. But if you don't mind my asking, what happened when you tried the
change? Did it generate an error or what? To answer your other question, I
don't think you can view the SQL with your parameter replaced by your value
, because SQL Server doesn't do a simple string-type replacement when you in
voke sp_executesql. You can add a PRINT @.sSQL right behind the SET @.sSQL st
atement, but it won't have your replacement value in it.
Thx,
Mike C.
"Mark Holahan" <mark.holahan@.unifiedllc.com> wrote in message news:%234xWobq
HFHA.2936@.TK2MSFTNGP15.phx.gbl...
Mike,
Thanks for your time. I'm going to post the question a little differently.
Mark
"Michael C#" <xyz@.yomomma.com> wrote in message news:ufFBc8pHFHA.4004@.TK2MSF
TNGP10.phx.gbl...
I'm having a little trouble installing Full-Text Search on my beat-up little
lap-top over here. So with the caveat that I haven't actually tested it, y
ou might try the following:
DECLARE @.Params NVARCHAR(50)
DECLARE @.sSQL NVARCHAR(1000)
DECLARE @.PropStreet1 VARCHAR(50)
SET @.PropStreet1 = '0-14115 Ironwood Dr'
-- changed the parameter in your query from @.PropStreet1 to @.AddressStreet1
and got rid of the + sign
SET @.sSQL = N'SELECT OrderNo, PropStreet1 FROM tbl_Orders WHERE CONTAINS(Pro
pStreet1, '' " @.AddressStreet1 " '')'
-- changed @.AddressStreet to @.AddressStreet1
SET @.Params = N' @.AddressStreet1 VARCHAR(50)'
EXEC sp_executesql @.sSQL, @.Params, @.AddressStreet1 = @.PropStreet1
I'll see if I can clean this little box up enough to get Full-Text Search in
stalled (it really needs to be re-formatted... ah well...)
Thx
Mike C.
Is it possible, when using sp_executesql, to see the SQL statement with the
parameters expanded?
I'm losing years of life trying to get the following dynamic SQL statement t
o work:
DECLARE @.sSQL NVARCHAR(1000)
DECLARE @.PropStreet1 VARCHAR(50)
SET @.PropStreet1 = '0-14115 Ironwood Dr'
SET @.sSQL = N'SELECT OrderNo, PropStreet1
FROM tbl_Orders
AND CONTAINS(PropStreet1, '' " + @.PropStreet1 " '')'
SET @.Params = N' @.AddressStreet VARCHAR(50)'
EXEC sp_executesql @.sSQL, @.Params, @.AddressStreet1 = @.PropStreet1
I don't get a syntax error; but I don't get a result set either. Whereas I d
o get a result set if I just run the plain-Jane Select query (w/o using sp_e
xecutesql).
Is there a way, in Profiler for example, that I could see how SQL Server exp
ands the parameter? That I could see the final SQL statement?
Thank you.
--
--
Mark HolahanI think I see what you're trying to do here, but just to be sure, can you po
st the exact "plain-Jane SQL query" you are running?
Thx,
Mike C
"Mark Holahan" <mark.holahan@.unifiedllc.com> wrote in message news:u7wQg5nHF
HA.3500@.TK2MSFTNGP14.phx.gbl...
Hi,
Is it possible, when using sp_executesql, to see the SQL statement with the
parameters expanded?
I'm losing years of life trying to get the following dynamic SQL statement t
o work:
DECLARE @.sSQL NVARCHAR(1000)
DECLARE @.PropStreet1 VARCHAR(50)
SET @.PropStreet1 = '0-14115 Ironwood Dr'
SET @.sSQL = N'SELECT OrderNo, PropStreet1
FROM tbl_Orders
AND CONTAINS(PropStreet1, '' " + @.PropStreet1 " '')'
SET @.Params = N' @.AddressStreet VARCHAR(50)'
EXEC sp_executesql @.sSQL, @.Params, @.AddressStreet1 = @.PropStreet1
I don't get a syntax error; but I don't get a result set either. Whereas I d
o get a result set if I just run the plain-Jane Select query (w/o using sp_e
xecutesql).
Is there a way, in Profiler for example, that I could see how SQL Server exp
ands the parameter? That I could see the final SQL statement?
Thank you.
--
--
Mark Holahan|||Mike,
Plain Jane:
SELECT OrderNo, PropStreet1
FROM tbl_Orders
WHERE CONTAINS(PropStreet1, ' "0-14115 Ironwood Dr" ')
I see that I left out the word "WHERE" below; this was an oversight.
Thanks.
"Michael C#" <xyz@.yomomma.com> wrote in message news:uOIjvKpHFHA.3484@.TK2MSF
TNGP12.phx.gbl...
I think I see what you're trying to do here, but just to be sure, can you po
st the exact "plain-Jane SQL query" you are running?
Thx,
Mike C
"Mark Holahan" <mark.holahan@.unifiedllc.com> wrote in message news:u7wQg5nHF
HA.3500@.TK2MSFTNGP14.phx.gbl...
Hi,
Is it possible, when using sp_executesql, to see the SQL statement with the
parameters expanded?
I'm losing years of life trying to get the following dynamic SQL statement t
o work:
DECLARE @.sSQL NVARCHAR(1000)
DECLARE @.PropStreet1 VARCHAR(50)
SET @.PropStreet1 = '0-14115 Ironwood Dr'
SET @.sSQL = N'SELECT OrderNo, PropStreet1
FROM tbl_Orders
AND CONTAINS(PropStreet1, '' " + @.PropStreet1 " '')'
SET @.Params = N' @.AddressStreet VARCHAR(50)'
EXEC sp_executesql @.sSQL, @.Params, @.AddressStreet1 = @.PropStreet1
I don't get a syntax error; but I don't get a result set either. Whereas I d
o get a result set if I just run the plain-Jane Select query (w/o using sp_e
xecutesql).
Is there a way, in Profiler for example, that I could see how SQL Server exp
ands the parameter? That I could see the final SQL statement?
Thank you.
--
--
Mark Holahan|||I'm having a little trouble installing Full-Text Search on my beat-up little
lap-top over here. So with the caveat that I haven't actually tested it, y
ou might try the following:
DECLARE @.Params NVARCHAR(50)
DECLARE @.sSQL NVARCHAR(1000)
DECLARE @.PropStreet1 VARCHAR(50)
SET @.PropStreet1 = '0-14115 Ironwood Dr'
-- changed the parameter in your query from @.PropStreet1 to @.AddressStreet1
and got rid of the + sign
SET @.sSQL = N'SELECT OrderNo, PropStreet1 FROM tbl_Orders WHERE CONTAINS(Pro
pStreet1, '' " @.AddressStreet1 " '')'
-- changed @.AddressStreet to @.AddressStreet1
SET @.Params = N' @.AddressStreet1 VARCHAR(50)'
EXEC sp_executesql @.sSQL, @.Params, @.AddressStreet1 = @.PropStreet1
I'll see if I can clean this little box up enough to get Full-Text Search in
stalled (it really needs to be re-formatted... ah well...)
Thx
Mike C.
"Mark Holahan" <mark.holahan@.unifiedllc.com> wrote in message news:uruEiRpHF
HA.720@.TK2MSFTNGP10.phx.gbl...
Mike,
Plain Jane:
SELECT OrderNo, PropStreet1
FROM tbl_Orders
WHERE CONTAINS(PropStreet1, ' "0-14115 Ironwood Dr" ')
I see that I left out the word "WHERE" below; this was an oversight.
Thanks.
"Michael C#" <xyz@.yomomma.com> wrote in message news:uOIjvKpHFHA.3484@.TK2MSF
TNGP12.phx.gbl...
I think I see what you're trying to do here, but just to be sure, can you po
st the exact "plain-Jane SQL query" you are running?
Thx,
Mike C
"Mark Holahan" <mark.holahan@.unifiedllc.com> wrote in message news:u7wQg5nHF
HA.3500@.TK2MSFTNGP14.phx.gbl...
Hi,
Is it possible, when using sp_executesql, to see the SQL statement with the
parameters expanded?
I'm losing years of life trying to get the following dynamic SQL statement t
o work:
DECLARE @.sSQL NVARCHAR(1000)
DECLARE @.PropStreet1 VARCHAR(50)
SET @.PropStreet1 = '0-14115 Ironwood Dr'
SET @.sSQL = N'SELECT OrderNo, PropStreet1
FROM tbl_Orders
AND CONTAINS(PropStreet1, '' " + @.PropStreet1 " '')'
SET @.Params = N' @.AddressStreet VARCHAR(50)'
EXEC sp_executesql @.sSQL, @.Params, @.AddressStreet1 = @.PropStreet1
I don't get a syntax error; but I don't get a result set either. Whereas I d
o get a result set if I just run the plain-Jane Select query (w/o using sp_e
xecutesql).
Is there a way, in Profiler for example, that I could see how SQL Server exp
ands the parameter? That I could see the final SQL statement?
Thank you.
--
--
Mark Holahan|||Mike,
Thanks for your time. I'm going to post the question a little differently.
Mark
"Michael C#" <xyz@.yomomma.com> wrote in message news:ufFBc8pHFHA.4004@.TK2MSF
TNGP10.phx.gbl...
I'm having a little trouble installing Full-Text Search on my beat-up little
lap-top over here. So with the caveat that I haven't actually tested it, y
ou might try the following:
DECLARE @.Params NVARCHAR(50)
DECLARE @.sSQL NVARCHAR(1000)
DECLARE @.PropStreet1 VARCHAR(50)
SET @.PropStreet1 = '0-14115 Ironwood Dr'
-- changed the parameter in your query from @.PropStreet1 to @.AddressStreet1
and got rid of the + sign
SET @.sSQL = N'SELECT OrderNo, PropStreet1 FROM tbl_Orders WHERE CONTAINS(Pro
pStreet1, '' " @.AddressStreet1 " '')'
-- changed @.AddressStreet to @.AddressStreet1
SET @.Params = N' @.AddressStreet1 VARCHAR(50)'
EXEC sp_executesql @.sSQL, @.Params, @.AddressStreet1 = @.PropStreet1
I'll see if I can clean this little box up enough to get Full-Text Search in
stalled (it really needs to be re-formatted... ah well...)
Thx
Mike C.
"Mark Holahan" <mark.holahan@.unifiedllc.com> wrote in message news:uruEiRpHF
HA.720@.TK2MSFTNGP10.phx.gbl...
Mike,
Plain Jane:
SELECT OrderNo, PropStreet1
FROM tbl_Orders
WHERE CONTAINS(PropStreet1, ' "0-14115 Ironwood Dr" ')
I see that I left out the word "WHERE" below; this was an oversight.
Thanks.
"Michael C#" <xyz@.yomomma.com> wrote in message news:uOIjvKpHFHA.3484@.TK2MSF
TNGP12.phx.gbl...
I think I see what you're trying to do here, but just to be sure, can you po
st the exact "plain-Jane SQL query" you are running?
Thx,
Mike C
"Mark Holahan" <mark.holahan@.unifiedllc.com> wrote in message news:u7wQg5nHF
HA.3500@.TK2MSFTNGP14.phx.gbl...
Hi,
Is it possible, when using sp_executesql, to see the SQL statement with the
parameters expanded?
I'm losing years of life trying to get the following dynamic SQL statement t
o work:
DECLARE @.sSQL NVARCHAR(1000)
DECLARE @.PropStreet1 VARCHAR(50)
SET @.PropStreet1 = '0-14115 Ironwood Dr'
SET @.sSQL = N'SELECT OrderNo, PropStreet1
FROM tbl_Orders
AND CONTAINS(PropStreet1, '' " + @.PropStreet1 " '')'
SET @.Params = N' @.AddressStreet VARCHAR(50)'
EXEC sp_executesql @.sSQL, @.Params, @.AddressStreet1 = @.PropStreet1
I don't get a syntax error; but I don't get a result set either. Whereas I d
o get a result set if I just run the plain-Jane Select query (w/o using sp_e
xecutesql).
Is there a way, in Profiler for example, that I could see how SQL Server exp
ands the parameter? That I could see the final SQL statement?
Thank you.
--
--
Mark Holahan|||No prob. But if you don't mind my asking, what happened when you tried the
change? Did it generate an error or what? To answer your other question, I
don't think you can view the SQL with your parameter replaced by your value
, because SQL Server doesn't do a simple string-type replacement when you in
voke sp_executesql. You can add a PRINT @.sSQL right behind the SET @.sSQL st
atement, but it won't have your replacement value in it.
Thx,
Mike C.
"Mark Holahan" <mark.holahan@.unifiedllc.com> wrote in message news:%234xWobq
HFHA.2936@.TK2MSFTNGP15.phx.gbl...
Mike,
Thanks for your time. I'm going to post the question a little differently.
Mark
"Michael C#" <xyz@.yomomma.com> wrote in message news:ufFBc8pHFHA.4004@.TK2MSF
TNGP10.phx.gbl...
I'm having a little trouble installing Full-Text Search on my beat-up little
lap-top over here. So with the caveat that I haven't actually tested it, y
ou might try the following:
DECLARE @.Params NVARCHAR(50)
DECLARE @.sSQL NVARCHAR(1000)
DECLARE @.PropStreet1 VARCHAR(50)
SET @.PropStreet1 = '0-14115 Ironwood Dr'
-- changed the parameter in your query from @.PropStreet1 to @.AddressStreet1
and got rid of the + sign
SET @.sSQL = N'SELECT OrderNo, PropStreet1 FROM tbl_Orders WHERE CONTAINS(Pro
pStreet1, '' " @.AddressStreet1 " '')'
-- changed @.AddressStreet to @.AddressStreet1
SET @.Params = N' @.AddressStreet1 VARCHAR(50)'
EXEC sp_executesql @.sSQL, @.Params, @.AddressStreet1 = @.PropStreet1
I'll see if I can clean this little box up enough to get Full-Text Search in
stalled (it really needs to be re-formatted... ah well...)
Thx
Mike C.
Sunday, February 19, 2012
Execution Snaption parameters
I am setting up an execution snapshot to run a query every day at 2:00 am to run a long query and store the report as a snapshot.
My question is my two parameters are Starting Date and Ending Date. I want the parameters to have the value of the previous date (being that the report is run at 2:00 am). Is is possible to set up an expression such as =today-1 for these parameters?
Thanks for the information.
that's true, = Today - 1 will be easyI suppose set the "default" value for BeginDate to a DataSet query
where you select the previous date in the query?
SELECT getdate() - 1|||Thanks...that worked and I did not even think about applying the query actually as the default report parameter.
Execution 'rgaerh55bisinzr1nlmr13jk' cannot be found (rsExecutionN
I have a SSRS 2005 SP1 running on Windows 2003 SRS. On reports with
parameters we are getting the following error.
Execution 'rgaerh55bisinzr1nlmr13jk' cannot be found (rsExecutionNotFound).
Anyone else seen this? Any suggestions on how to resolve this?
Thanks.Yes, we are seeing the same thing.
In our case, the report runs the first time, with the default parameters --
which says that there's an aweful lot of setup that is functioning just fine.
Then, upon changing a parameter and pressing "View Report", the following
obscure error shows up:
Execution 'qr1hx055hlpkx445xluqd4yv' cannot be found (rsExecutionNotFound)
It also occurs when simply pressing "View Report", with no changes to
parameters.
"rdwill1" wrote:
> I have a SSRS 2005 SP1 running on Windows 2003 SRS. On reports with
> parameters we are getting the following error.
> Execution 'rgaerh55bisinzr1nlmr13jk' cannot be found (rsExecutionNotFound).
> Anyone else seen this? Any suggestions on how to resolve this?
> Thanks.
parameters we are getting the following error.
Execution 'rgaerh55bisinzr1nlmr13jk' cannot be found (rsExecutionNotFound).
Anyone else seen this? Any suggestions on how to resolve this?
Thanks.Yes, we are seeing the same thing.
In our case, the report runs the first time, with the default parameters --
which says that there's an aweful lot of setup that is functioning just fine.
Then, upon changing a parameter and pressing "View Report", the following
obscure error shows up:
Execution 'qr1hx055hlpkx445xluqd4yv' cannot be found (rsExecutionNotFound)
It also occurs when simply pressing "View Report", with no changes to
parameters.
"rdwill1" wrote:
> I have a SSRS 2005 SP1 running on Windows 2003 SRS. On reports with
> parameters we are getting the following error.
> Execution 'rgaerh55bisinzr1nlmr13jk' cannot be found (rsExecutionNotFound).
> Anyone else seen this? Any suggestions on how to resolve this?
> Thanks.
Subscribe to:
Posts (Atom)