Friday, March 30, 2012
OpenQuery with variable
select field1, field2,... from openquery(LinkedServerName, 'select * from
tablename where field =' + @.myVar)
the problem is that openquery does not admit statement to be composed by
concatted strings...how to solve it?You need to build the entire SQL statement as a string and
then pass that string to an EXEC.
You can find more information and an example in the
following article:
HOW TO: Pass a Variable to a Linked Server Query
http://support.microsoft.com/?id=314520
-Sue
On Tue, 24 Jan 2006 08:52:01 -0800, "Roberto Lo Baido"
<RobertoLoBaido@.discussions.microsoft.com> wrote:
>I need to do this:
>select field1, field2,... from openquery(LinkedServerName, 'select * from
>tablename where field =' + @.myVar)
>the problem is that openquery does not admit statement to be composed by
>concatted strings...how to solve it?
OpenQuery with variable
select field1, field2,... from openquery(LinkedServerName, 'select * from
tablename where field =' + @.myVar)
the problem is that openquery does not admit statement to be composed by
concatted strings...how to solve it?You need to build the entire SQL statement as a string and
then pass that string to an EXEC.
You can find more information and an example in the
following article:
HOW TO: Pass a Variable to a Linked Server Query
http://support.microsoft.com/?id=314520
-Sue
On Tue, 24 Jan 2006 08:52:01 -0800, "Roberto Lo Baido"
<RobertoLoBaido@.discussions.microsoft.com> wrote:
>I need to do this:
>select field1, field2,... from openquery(LinkedServerName, 'select * from
>tablename where field =' + @.myVar)
>the problem is that openquery does not admit statement to be composed by
>concatted strings...how to solve it?sql
Tuesday, March 20, 2012
open query help
number but I am having major problems using strings.
I have tried a few solutions including the usual concantenations but no
solution. Is there a simple way of including strings with the filters
for a query below, possibly without declaring variables and using the
string directly in the code? I have included one of the solutions I was
given..
Thankyou for any help ...
DECLARE @.SQL VARCHAR(8000) DECLARE @.strVar VARCHAR(1000)
SET @.strVar = '22'
SET @.SQL = '
select * FROM OPENQUERY(ISERIES,
"SELECT OOLINE.OBWHLO, OOLINE.OBCUNO, OCUSMA.OKCUNM, OOLINE.OBORNO,
OOLINE.OBPONR, OOLINE.OBITNO, OOLINE.OBDWDZ, OOLINE.OBORQA,
OOLINE.OBATV3, OOLINE.OBATV4,
OOLINE.OBATV5, OOLINE.OBROUT, OOHEAD.OADLSP, OOHEAD.OADSTX,
OCUSAD.OPCUNM, OCUSAD.OPCUA1, OCUSAD.OPCUA2, OCUSAD.OPCUA3,
OCUSAD.OPCUA4, MHDISH.OQDLIX, OOHEAD.OAFACI, CFACIL.CFFACN,
OOHEAD.OARGDT, OOHEAD.OAPRTX, mitbal.MBPUIT, mitbal.MBSUWH,
OOHEAD.OARESP, OOHEAD.OARGTM, OOLINE.OBORST, mitbal.MBOPLC,
(OOLINE.OBATV0) As mark_no,(OOHEAD.OACUOR) As po_no,OOLINE.OBATV6) As
cust_bund_ID,OOLINE.OBFACI,(OOLINE.OBRORN) As DO_no, MHDISH.OQDSDT
FROM
mvxcdtprod.OOHEAD oohead INNER JOIN mvxcdtprod.OCUSAD ocusad ON
OOHEAD.OACONO = OCUSAD.OPCONO
AND OOHEAD.OACUNO = OCUSAD.OPCUNO
AND OOHEAD.OAADID = OCUSAD.OPADID
INNER JOIN mvxcdtprod.CFACIL cfacil ON OOHEAD.OACONO = CFACIL.CFCONO
AND OOHEAD.OADIVI = CFACIL.CFDIVI
AND OOHEAD.OAFACI = CFACIL.CFFACI
INNER JOIN mvxcdtprod.OCUSMA ocusma ON OOHEAD.OACONO =
OCUSMA.OKCONO AND OOHEAD.OACUNO = OCUSMA.OKCUNO
INNER JOIN mvxcdtprod.OOLINE ooline ON OOHEAD.OACONO =
OOLINE.OBCONO AND OOHEAD.OAORNO = OOLINE.OBORNO
INNER JOIN mvxcdtprod.MITBAL mitbal ON OOLINE.OBCONO =
MITBAL.MBCONO AND OOLINE.OBWHLO = MITBAL.MBWHLO
AND OOLINE.OBITNO = MITBAL.MBITNO
INNER JOIN mvxcdtprod.MITMAS mitmas ON OOLINE.OBCONO =
MITMAS.MMCONO AND OOLINE.OBITNO = MITMAS.MMITNO
LEFT OUTER JOIN mvxcdtprod.MHDISL mhdisl ON MHDISL.URRIDN =
OOLINE.OBORNO
AND MHDISL.URRIDL/100 = OOLINE.OBPONR
AND MHDISL.URCONO = OOLINE.OBCONO
LEFT OUTER JOIN mvxcdtprod.mhdish mhdish ON OOLINE.OBCONO =
MHDISH.OQCONOAND MHDISL.URDLIX = MHDISH.OQDLIX
WHERE mitbal.MBOPLC = 3 and OOLINE.OBORST = ('' + @.strVar +
'')'') '
EXEC(@.SQL)(david.good@.stramit.com.au) writes:
> Adding numerical field to filters in openquery is as easy as typing the
> number but I am having major problems using strings.
> I have tried a few solutions including the usual concantenations but no
> solution. Is there a simple way of including strings with the filters
> for a query below, possibly without declaring variables and using the
> string directly in the code? I have included one of the solutions I was
> given..
I'm not really sure what your question is, but due to the rigid syntax
of OPENQUERY, you often end up with several layers of nested quotes,
and it can be very difficult to get it right. One comment to the query:
> select * FROM OPENQUERY(ISERIES,
> "SELECT OOLINE.OBWHLO, OOLINE.OBCUNO, OCUSMA.OKCUNM,
This works if the setting QUOTED_IDENTIFIER is OFF. The default for this
settings (in most contexts) is ON. When ON, "" delimits identifiers, not
string literals. Setting this setting to OFF can indeed be useful for
this kind of exercises, since you get two different quote operators
to play with. (But obsever that turning off this setting is not good
if there are indexed views or indexed computed columns around.)
One alternative is to build the string piece by piece. To this end
the function quotestring() may be helpful, see
http://www.sommarskog.se/dynamic_sql.html#quotestring.
--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp
Friday, March 9, 2012
Open a url in a new window
I try to pass some field values to a url and render it to a web application.
I tried to do it with a javascript function
javascript:if(window.open('http://server?id=' &
Fields!ID.Value,'Popups','width=400,height=500,location=0,menubar=0,status=0,toolbar=0,scrollbars=1',true)){}
But I had no luck with it. Could someone assist me on this? Thanks!another option would be to use the "Target=_New" in the URL properties.
<a target="_blank" href="http://links.10026.com/?link=the/">http://www.URL.com">The Bible</a>
"fru" wrote:
> I'm trying to do something as follows:
> I try to pass some field values to a url and render it to a web application.
> I tried to do it with a javascript function
> javascript:if(window.open('http://server?id=' &
> Fields!ID.Value,'Popups','width=400,height=500,location=0,menubar=0,status=0,toolbar=0,scrollbars=1',true)){}
> But I had no luck with it. Could someone assist me on this? Thanks!|||I'm trying to address the url to a web application from a report server not
vice versa.
"mresanchez" wrote:
> another option would be to use the "Target=_New" in the URL properties.
> <a target="_blank" href="http://links.10026.com/?link=the/">http://www.URL.com">The Bible</a>
> "fru" wrote:
> > I'm trying to do something as follows:
> >
> > I try to pass some field values to a url and render it to a web application.
> > I tried to do it with a javascript function
> > javascript:if(window.open('http://server?id=' &
> > Fields!ID.Value,'Popups','width=400,height=500,location=0,menubar=0,status=0,toolbar=0,scrollbars=1',true)){}
> >
> > But I had no luck with it. Could someone assist me on this? Thanks!
Open a new report in a new window from existing
I need to open a new RS report from an existing RS report when the user
selects a distinct week # field.
I realize I right click the field / Properties / Advanced / Navigation I
believe I need to use the jump to URL.
I suspect I need a java script to create the new window with the report.
Can someone provide for me an example of the Java script necessary and
clarify my directions.
Also, does anyone know if this is explained WHERE I can find it in the
Hitchhikers Guide to Reporting Services - I have a copy and can not find the
resolution. I understand it is in Teo's book MS RS in Action; which I dont
own. All suggestions are welcome.
Thanks you in advance
Stuart
inventoryguy@.hotmail.comThis was introduced with SP1 which might be why it is not in your book. Here
is the syntax:
Here is an example of a Jump to URL link I use. This causes Excel to come up
with the data in a separate window:
="javascript:void(window.open('" & Globals!ReportServerUrl &
"?/SomeFolder/SomeReport&ParamName=" & Parameters!ParamName.Value &
"&rs:Format=CSV&rc:Encoding=ASCII','_blank'))"
If you remove the format and encoding it will come up in HTML (the default
format if nothing is specified)
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Stuart@.ICS" <inventory@.inventory.com> wrote in message
news:%23mau5rd9FHA.2792@.TK2MSFTNGP11.phx.gbl...
> Hello all:
> I need to open a new RS report from an existing RS report when the user
> selects a distinct week # field.
> I realize I right click the field / Properties / Advanced / Navigation I
> believe I need to use the jump to URL.
> I suspect I need a java script to create the new window with the report.
> Can someone provide for me an example of the Java script necessary and
> clarify my directions.
> Also, does anyone know if this is explained WHERE I can find it in the
> Hitchhikers Guide to Reporting Services - I have a copy and can not find
> the resolution. I understand it is in Teo's book MS RS in Action; which I
> dont own. All suggestions are welcome.
> Thanks you in advance
> Stuart
> inventoryguy@.hotmail.com
>|||Hello Bruce:
I get a URI Scheme is not valid error when I test the report.
My goal to to have a link off a field in report 1 when clicked open another
RS report in a new window.
The line I used is:
"javascript:void(window.open("https://server/ReportServer?%2fPRJfolder%2fRPTname"
& "&rs:Command=Render", "_blank",
"location=no,toolbar=no,left=100,top=100,height=600,width=800"))"
We have SP1 loaded.
Can you tell me where we have errored in our code?
If we need to pass parameters how would the line be different, I the
similances of that in your code but would like to make certain of all your
suggestions.
Again, thank you for the help.
Stuart
"Bruce L-C [MVP]" <bruce_lcNOSPAM@.hotmail.com> wrote in message
news:eKs5Vbf9FHA.1844@.TK2MSFTNGP11.phx.gbl...
> This was introduced with SP1 which might be why it is not in your book.
> Here is the syntax:
> Here is an example of a Jump to URL link I use. This causes Excel to come
> up with the data in a separate window:
> ="javascript:void(window.open('" & Globals!ReportServerUrl &
> "?/SomeFolder/SomeReport&ParamName=" & Parameters!ParamName.Value &
> "&rs:Format=CSV&rc:Encoding=ASCII','_blank'))"
> If you remove the format and encoding it will come up in HTML (the default
> format if nothing is specified)
>
> --
> Bruce Loehle-Conger
> MVP SQL Server Reporting Services
>
> "Stuart@.ICS" <inventory@.inventory.com> wrote in message
> news:%23mau5rd9FHA.2792@.TK2MSFTNGP11.phx.gbl...
>> Hello all:
>> I need to open a new RS report from an existing RS report when the user
>> selects a distinct week # field.
>> I realize I right click the field / Properties / Advanced / Navigation I
>> believe I need to use the jump to URL.
>> I suspect I need a java script to create the new window with the report.
>> Can someone provide for me an example of the Java script necessary and
>> clarify my directions.
>> Also, does anyone know if this is explained WHERE I can find it in the
>> Hitchhikers Guide to Reporting Services - I have a copy and can not find
>> the resolution. I understand it is in Teo's book MS RS in Action; which
>> I dont own. All suggestions are welcome.
>> Thanks you in advance
>> Stuart
>> inventoryguy@.hotmail.com
>>
>|||One thing I suggest, try it without any report first. Open up another web
page, google or whatever. Then you can make sure that you are using it
properly. Then open a report. One thing I am not sure of is the syntax you
you for location etc).
Looking at you have done, you are not doing what I did. I have single quotes
in places where you modified it to use double quotes. You are assembling a
string here. I use double quotes only between strings and then I have and &
concatenating the string. Look at mine closely, it was a working example.
The only place double quotes are used will have an ampersand either before
it or after it depending on whether I am starting a new string or ending it.
Looking at yours (not even worrying about what you have actual put there)
but without a doubt it is totally wrong just because of your use of double
quotes.
One easy thing to do, have a text box in a report. No dataset. Just a report
with a single text box. Set the source of the textbox to this expression so
you can see the result. Until you get the quotes correct it will keep
erroring out. Then once you have that correct you can see what your
resulting string looks like.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Stuart@.ICS" <inventory@.inventory.com> wrote in message
news:%23TDOQ0f9FHA.3804@.TK2MSFTNGP14.phx.gbl...
> Hello Bruce:
> I get a URI Scheme is not valid error when I test the report.
> My goal to to have a link off a field in report 1 when clicked open
> another RS report in a new window.
> The line I used is:
> "javascript:void(window.open("https://server/ReportServer?%2fPRJfolder%2fRPTname"
> & "&rs:Command=Render", "_blank",
> "location=no,toolbar=no,left=100,top=100,height=600,width=800"))"
> We have SP1 loaded.
> Can you tell me where we have errored in our code?
> If we need to pass parameters how would the line be different, I the
> similances of that in your code but would like to make certain of all your
> suggestions.
> Again, thank you for the help.
> Stuart
>
> "Bruce L-C [MVP]" <bruce_lcNOSPAM@.hotmail.com> wrote in message
> news:eKs5Vbf9FHA.1844@.TK2MSFTNGP11.phx.gbl...
>> This was introduced with SP1 which might be why it is not in your book.
>> Here is the syntax:
>> Here is an example of a Jump to URL link I use. This causes Excel to come
>> up with the data in a separate window:
>> ="javascript:void(window.open('" & Globals!ReportServerUrl &
>> "?/SomeFolder/SomeReport&ParamName=" & Parameters!ParamName.Value &
>> "&rs:Format=CSV&rc:Encoding=ASCII','_blank'))"
>> If you remove the format and encoding it will come up in HTML (the
>> default format if nothing is specified)
>>
>> --
>> Bruce Loehle-Conger
>> MVP SQL Server Reporting Services
>>
>> "Stuart@.ICS" <inventory@.inventory.com> wrote in message
>> news:%23mau5rd9FHA.2792@.TK2MSFTNGP11.phx.gbl...
>> Hello all:
>> I need to open a new RS report from an existing RS report when the user
>> selects a distinct week # field.
>> I realize I right click the field / Properties / Advanced / Navigation I
>> believe I need to use the jump to URL.
>> I suspect I need a java script to create the new window with the report.
>> Can someone provide for me an example of the Java script necessary and
>> clarify my directions.
>> Also, does anyone know if this is explained WHERE I can find it in the
>> Hitchhikers Guide to Reporting Services - I have a copy and can not find
>> the resolution. I understand it is in Teo's book MS RS in Action; which
>> I dont own. All suggestions are welcome.
>> Thanks you in advance
>> Stuart
>> inventoryguy@.hotmail.com
>>
>>
>
Wednesday, March 7, 2012
Only show field on last page
i would like to show some fields only on the last page on the report. How can i achieve this?
(The field is in the body area)
King regards,
Christian NiehavesYou can exactly control the report pagination if this is what you after but if the fields are at the end of the report body (below the main report region) they will show last on the report.|||Hallo,
is there any possiblity to get the current page number and the total number of pages in the body area of a report?
King regards
Christian Niehaves|||The only way I know of is to pass the page number to a code-behind variable in the page footer and read it in the report body.|||
I have only rdl file, how to pass the page number to a code-behind variable ? I think i can't to do that via xml.
|||The idea was to create a VB.NET variable in the report properties Code tab. Since PageNumber and TotalPages are available only in the page header/footer, use one of the exression-based properties of the Page Header band to set the variable and then read it from the Textbox in the body section, e.g. =Code._PageNumber (assuming that _PageNumber is the variable).|||I'm understood it, but i have the report server project generated by wizard, and seems to me that i don't have VB or C# codebehind, only rdl file with xml syntax. How i can place current page number into the body of report?
Sorry for my English.
Thank you.
|||I attempted to add expressions =ReportItems!TextboxInHeader.Value for field in the body and i've got compiling error:
Error 1 [rsReportItemReference] The Value expression for the textbox ‘textboxInBody’ refers to the report item ‘TextboxInHeader’. Report item expressions can only refer to other report items within the same grouping scope or a containing grouping scope.
|||You cannot cross-reference items in different bands. Actually, I appologize for giving a wrong page number hack. Pseudo-events like these (setting a var in one band and reading it in another) were working (but were not supported) in RS 2000. In RS 2005, the expression execution order was changed. The net effect is that when reading the variable in the body section, you won't be able to "see" the changes made by the bands. This effectively means that there is no way that I know of to pass a page number to the body section.|||Thank you.Only show field on last page
i would like to show some fields only on the last page on the report. How can i achieve this?
(The field is in the body area)
King regards,
Christian NiehavesYou can exactly control the report pagination if this is what you after but if the fields are at the end of the report body (below the main report region) they will show last on the report.|||Hallo,
is there any possiblity to get the current page number and the total number of pages in the body area of a report?
King regards
Christian Niehaves|||The only way I know of is to pass the page number to a code-behind variable in the page footer and read it in the report body.|||
I have only rdl file, how to pass the page number to a code-behind variable ? I think i can't to do that via xml.
|||The idea was to create a VB.NET variable in the report properties Code tab. Since PageNumber and TotalPages are available only in the page header/footer, use one of the exression-based properties of the Page Header band to set the variable and then read it from the Textbox in the body section, e.g. =Code._PageNumber (assuming that _PageNumber is the variable).|||I'm understood it, but i have the report server project generated by wizard, and seems to me that i don't have VB or C# codebehind, only rdl file with xml syntax. How i can place current page number into the body of report?
Sorry for my English.
Thank you.
|||I attempted to add expressions =ReportItems!TextboxInHeader.Value for field in the body and i've got compiling error:
Error 1 [rsReportItemReference] The Value expression for the textbox ‘textboxInBody’ refers to the report item ‘TextboxInHeader’. Report item expressions can only refer to other report items within the same grouping scope or a containing grouping scope.
|||You cannot cross-reference items in different bands. Actually, I appologize for giving a wrong page number hack. Pseudo-events like these (setting a var in one band and reading it in another) were working (but were not supported) in RS 2000. In RS 2005, the expression execution order was changed. The net effect is that when reading the variable in the body section, you won't be able to "see" the changes made by the bands. This effectively means that there is no way that I know of to pass a page number to the body section.|||Thank you.Saturday, February 25, 2012
Only displaying the subtotal value in a matrix report.
If you add a toggle to the matrix column/row group, it will enable to switch between the detailed group instances (when expanded) or show the subtotals only (when collapsed). Take a look at the "Company Sales" sample report in the Adventure Works sample project that comes with RS.
-- Robert