Showing posts with label code. Show all posts
Showing posts with label code. Show all posts

Friday, March 30, 2012

Regarding Custom Code using table or list control(data set)

I have the report like this

list1

{

list2

{

table1

table header

table fields

table footer

}

}

now i want to calculate the sum of one field in table when it contains particular value using CUSTOM CODE ONLY

and i want to display it in table footer. please send me answer to this id as soon as possible.

Thanks

Sateesh Maduri

Maybe I'm missing something, but couldn't you just use a conditional aggregation expression like the following in the table footer:

=Sum(iif(Fields!A.Value = "abc", CInt(Fields!B.Value), 0))

-- Robert

|||

Hello Robert

Actually I already know that what u have given using sum().But I need Custom Code for that ,I mean if I have a dataset which fills the data in the table control How should I write Custom Code to calculate sum of one field when it contains particular value.

Thanks

sql

Regarding Custom Code

Hello

I have report like this

list1

list2(includes in list1)

table (includes in list2)

end of list2

end of list1

Now I want to calculate the sum of one column in table when it contains particular value and I want to display in table footer . I already know using sum() fuction.I want to know using custom code calculation for the above problem(How Can I repeat my data set in Custom code function for each row). So , If anyone knows Please reply.

It's Very Urgent

Thanks

Have a look at these

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=541699&SiteID=1

http://blogs.msdn.com/bwelcker/archive/2005/05/10/416306.aspx

Wednesday, March 28, 2012

Reg. scatter chart in reporting services

We are working with scatter chart in reporting services.we need to divide the chart into quadrants.We can use VB code in reporting services.Can anyone let me know the VB code to divide that into quadrants and coloring the quadrants

Thanks in advance

Subha

Can you give me sample data ,the example what you are showing now and what you want to show?|||

RED ORANGE GREEN BLACK

This is our requirement.The Scatter chart should be divided into 4 quadrants and

The quadrant backgrounds need to be colored as shown.

This is a quadrant analysis plot of Location versus Index Value

Thanks

Subha

|||Hey Subha Did you got the solution of your problem i also need same solution

reg. ReportService2005.asmx.

I am new to Reporting Service, I got the sample code, there is a method used
to connect reporting service,
http://servername/reports/ReportService2005.asmx,
But i don't find ReportService2005.asmx.
I chekced http://servername/reports/ folder ts is not there, how to get this
file? Is there any separate installtion/configuration needed?
I searched web, i don't find any information regarding this.
pl. any help
thanks
KalYou need to use http://servername/ReportServer/ReportService2005.asmx
/Reports is the web interface for Reporting Services whereas /ReportServer
is the Web Service interface.
--
Chris Alton, Microsoft Corp.
SQL Server Developer Support Engineer
This posting is provided "AS IS" with no warranties, and confers no rights.
--
> Thread-Topic: reg. ReportService2005.asmx.
> From: =?Utf-8?B?S2FseWFu?= <Kalyan@.discussions.microsoft.com>
> Subject: reg. ReportService2005.asmx.
> Date: Mon, 8 Oct 2007 06:02:17 -0700
> I am new to Reporting Service, I got the sample code, there is a method
used
> to connect reporting service,
> http://servername/reports/ReportService2005.asmx,
> But i don't find ReportService2005.asmx.
> I chekced http://servername/reports/ folder ts is not there, how to get
this
> file? Is there any separate installtion/configuration needed?
> I searched web, i don't find any information regarding this.
>
> pl. any help
>
> thanks
> Kal
>|||Thanks Chris,
"Chris Alton [MSFT]" wrote:
> You need to use http://servername/ReportServer/ReportService2005.asmx
> /Reports is the web interface for Reporting Services whereas /ReportServer
> is the Web Service interface.
> --
> Chris Alton, Microsoft Corp.
> SQL Server Developer Support Engineer
> This posting is provided "AS IS" with no warranties, and confers no rights.
> --
> > Thread-Topic: reg. ReportService2005.asmx.
> > From: =?Utf-8?B?S2FseWFu?= <Kalyan@.discussions.microsoft.com>
> > Subject: reg. ReportService2005.asmx.
> > Date: Mon, 8 Oct 2007 06:02:17 -0700
> >
> > I am new to Reporting Service, I got the sample code, there is a method
> used
> > to connect reporting service,
> >
> > http://servername/reports/ReportService2005.asmx,
> >
> > But i don't find ReportService2005.asmx.
> >
> > I chekced http://servername/reports/ folder ts is not there, how to get
> this
> > file? Is there any separate installtion/configuration needed?
> >
> > I searched web, i don't find any information regarding this.
> >
> >
> > pl. any help
> >
> >
> > thanks
> > Kal
> >
>|||Not a problem :)
--
Chris Alton, Microsoft Corp.
SQL Server Developer Support Engineer
This posting is provided "AS IS" with no warranties, and confers no rights.
--
> Thread-Topic: reg. ReportService2005.asmx.
> From: =?Utf-8?B?S2FseWFu?= <Kalyan@.discussions.microsoft.com>
> References: <5D2E4DAA-6C21-4138-89A1-4109357A14BA@.microsoft.com>
<7snSqEbCIHA.360@.TK2MSFTNGHUB02.phx.gbl>
> Subject: RE: reg. ReportService2005.asmx.
> Date: Mon, 8 Oct 2007 06:54:01 -0700
> Thanks Chris,
>
> "Chris Alton [MSFT]" wrote:
> > You need to use http://servername/ReportServer/ReportService2005.asmx
> >
> > /Reports is the web interface for Reporting Services whereas
/ReportServer
> > is the Web Service interface.
> >
> > --
> > Chris Alton, Microsoft Corp.
> > SQL Server Developer Support Engineer
> > This posting is provided "AS IS" with no warranties, and confers no
rights.
> > --
> > > Thread-Topic: reg. ReportService2005.asmx.
> > > From: =?Utf-8?B?S2FseWFu?= <Kalyan@.discussions.microsoft.com>
> > > Subject: reg. ReportService2005.asmx.
> > > Date: Mon, 8 Oct 2007 06:02:17 -0700
> > >
> > > I am new to Reporting Service, I got the sample code, there is a
method
> > used
> > > to connect reporting service,
> > >
> > > http://servername/reports/ReportService2005.asmx,
> > >
> > > But i don't find ReportService2005.asmx.
> > >
> > > I chekced http://servername/reports/ folder ts is not there, how to
get
> > this
> > > file? Is there any separate installtion/configuration needed?
> > >
> > > I searched web, i don't find any information regarding this.
> > >
> > >
> > > pl. any help
> > >
> > >
> > > thanks
> > > Kal
> > >
> >
> >
>

Monday, March 26, 2012

Reg JDBC MS sQLSERVer driver SP2

Hi
Has anyone used ResultSet.first(), ResultSet.beforeFirst(), ResultSet.AfterLast(), ResultSet.absolute(1) methods
in your JSP code, while connecting to SQL Server 2000, using MS SQLSERVER JDBC driver SP2 ?
I am hving problems with it., as it keeps throwing the msg, SQLSERVER 2000 driver for JDBC - unsupported mehod error for all the above calls. I am using JRUN server on DM2k MX to run my JSP.
I would appreciate your replies,
Thanks
Suma
"SumaJDBC" <anonymous@.discussions.microsoft.com> wrote in message
news:015E27EC-8BFC-49B6-96FD-669661A86912@.microsoft.com...
> Hi
> Has anyone used ResultSet.first(), ResultSet.beforeFirst(),
ResultSet.AfterLast(), ResultSet.absolute(1) methods
> in your JSP code, while connecting to SQL Server 2000, using MS SQLSERVER
JDBC driver SP2 ?
> I am hving problems with it., as it keeps throwing the msg, SQLSERVER 2000
driver for JDBC - unsupported mehod error for all the above calls. I am
using JRUN server on DM2k MX to run my JSP.
> I would appreciate your replies,
> Thanks
> Suma
What do you not understand about the error message? The calls are not
supported by the driver. In general it is best to stay away from them
anyway, simply stick to next(). It will give you optimal performance and
works on all JDBC drivers.
Silvio Bierman
|||Hi silvio
Thanks for your reply. I did use next(), but I am having wierd problem with that . I have to construct a dropdown box
, populating it from the database table values.
I connect to the DB, retrieve the required column values into the result set rs.
As I display the values , the first record is always being skipped and it is always picking up from second record onwards. Now can now U understand why I need to place rs.beforeFirst(), prior to the starting of that while loop!
or is there any other way of doing this? I am new to this , thus would appreciate an expert advice!
here's my scriptlet after (connection to the Db and populatinf the ResultSet rs (using a javabean (db) class for this )
try{
//rs.beforeFirst();
while(rs.next()) {
%><option value=<%=rs.getString("DeptName")%></option><BR><%
}
} catch (Exception e) {
msg = e.getMessage();
out.println(msg);
}
%><% db.close();%></select>
|||"SumaJDBC" <anonymous@.discussions.microsoft.com> wrote in message
news:3D950D2F-8ACE-468E-97AD-A6D33DDCC897@.microsoft.com...
> Hi silvio
> Thanks for your reply. I did use next(), but I am having wierd problem
with that . I have to construct a dropdown box
> , populating it from the database table values.
> I connect to the DB, retrieve the required column values into the result
set rs.
> As I display the values , the first record is always being skipped and it
is always picking up from second record onwards. Now can now U understand
why I need to place rs.beforeFirst(), prior to the starting of that while
loop!
> or is there any other way of doing this? I am new to this , thus would
appreciate an expert advice!
> here's my scriptlet after (connection to the Db and populatinf the
ResultSet rs (using a javabean (db) class for this )
> try{
> //rs.beforeFirst();
> while(rs.next()) {
>
> %><option value=<%=rs.getString("DeptName")%></option><BR><%
> }
> } catch (Exception e) {
> msg = e.getMessage();
> out.println(msg);
> }
> %><% db.close(); %></select>
I have heard that problem previously several times and each time it was an
error in the application code that caused the behaviour. Using
ResultSet rs = ...;
while (rs.next()) //process current row
should work always. If it doesn't something is seriously broken and the
methods you mention can;t help you. I would suggest you post some actual
code that produces the behaviour.
Silvio Bierman
|||Hi Silvio,
As U suggested I tried to look into my code for possible logical errors, but couldnt find any,. So I am posting my code below:
Thanks in advance (again) for taking time to answer my queries.
Suma
// This is DbConnection.java, the bean class for getting the DBconnection and excecuting DB related methods
package BeanClasses;
import java.sql.*;
import java.io.*;
import java.lang.*;
public class DbConnection{
String dbURL = "jdbc:microsoft:sqlserver://sql1;databaseName=DEVPurContr";
String dbDriver = "com.microsoft.jdbc.sqlserver.SQLServerDriver" ;
private Connection dbCon;
public String temp;
public String getTemp() { return temp;
}
public void setTemp (String Temp){
this.temp = Temp;
}
public DbConnection() {
super();
/*try {
connect();
} catch (Exception e) { }*/
}
public boolean connect () throws Exception { //This functionis called first get a valid connection
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLSer verDriver");
dbCon = DriverManager.getConnection(dbURL,"webuser","webus er3070");
}
catch (Exception e) { System.out.println(e.getMessage());
}
return true;
}
public void close() throws SQLException {
dbCon.close();
}
public ResultSet execSQL (String sql) throws SQLException { //This function is called to retrive the result set
// String (sql) is supplied at the run time, which is my select statement and the returned
// result set.
Statement s = dbCon.createStatement();
ResultSet r = s.executeQuery(sql);
return (r==null) ? null : r;
}
public int execUpdate (String sql ) throws SQLException {
Statement s = dbCon.createStatement ();
int r = s.executeUpdate (sql);
return (r==0) ? -1 : r ;
}
}
// Here's my import , where I am importing relevant java packages
<%@. page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*,java.util.*,java.lang.*,java.io .*" errorPage="" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head>
// Heres's JSP code (relevant part )
<tr><td class="RequiredDetail" style="text-align:left;"><span style="color:white; font-size:10px; font-weight:bolder"></span>
Enter Department Name
</td><td style="text-align:right;"><select name="DeptName"><%
ResultSet rs = null;
int i;
%><%
String msg;
db.connect(); // Call to the bean
try {
rs = db.execSQL("SELECT distinct DeptName FROM tblDepartment order by DeptName" ); // call to the bean
} catch(Exception e) {
msg = e.getMessage();
}
try{
//rs.beforeFirst();
while(rs.next()) {
out.println(rs.getString("DeptName"));
%><option value=<%=rs.getString("DeptName")%></option><BR><%
}
} catch (Exception e) {
msg = e.getMessage();
out.println(msg);
}
%><% db.close();%></select></td></tr>
|||As far is I can tell from this code there is no reason for the strange
behaviour. Have you tried running it in a normal application instead of a
JSP page (I have little experience with JSPs)? Have you compared such
results with running the same query from the Query Analyzer?
Silvio Bierman
|||Hi
Yes. I have run the query (thru JDBC) on regular java compiler. I have also done it on sql analyzer. In both cases the behavior is as exepected. But in JSP, when I use MS SQL Server JDBC driver. I get this odd results.
I still fail to understand why MS JDBC driver fails to support ResultSet.beforeFirst () and ResultSet.afterLast() functions?
Suma
|||te cuento que tengo el mismo problema con ResultSet.absolute(1) methods in your JSP code, while connecting to SQL Server 2000, using MS SQLSERVER JDBC driver SP2 ?
pero se logra solucionar con el drive JnetDirect pero tienes que comprarlo yo se que esa no es la idea por favor ayudame si hallas la solucion
Gracias
************************************************** ********************
Sent via Fuzzy Software @. http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
|||trivadeneira@.olade.org.ec wrote:

> te cuento que tengo el mismo problema con ResultSet.absolute(1) methods in your JSP code, while connecting to SQL Server 2000, using MS SQLSERVER JDBC driver SP2 ?
> pero se logra solucionar con el drive JnetDirect pero tienes que comprarlo yo se que esa no es la idea por favor ayudame si hallas la solucion
>
> Gracias
Hola. Si un mtodo falla con el MS jdbc conductor libre,
usted debe esperar o antes de que ellos liberen a su
siguiente conductor, y esperen que sea fijado entonces,
o usted puede usar un producto comercial.
El DataDirect es el negocio que realmente hace el
JDBC conductor de MS., entonces usted debera intentar su
conductor. Esto mostrar si el siguiente conductor de
los MS ser fijado.

>
> ************************************************** ********************
> Sent via Fuzzy Software @. http://www.fuzzysoftware.com/
> Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
|||trivadeneira@.olade.org.ec wrote:

> te cuento que tengo el mismo problema con ResultSet.absolute(1) methods in your JSP code, while connecting to SQL Server 2000, using MS SQLSERVER JDBC driver SP2 ?
> pero se logra solucionar con el drive JnetDirect pero tienes que comprarlo yo se que esa no es la idea por favor ayudame si hallas la solucion
>
> Gracias
Hola. Si un mtodo falla con el MS jdbc conductor libre,
usted debe esperar o antes de que ellos liberen a su
siguiente conductor, y esperen que sea fijado entonces,
o usted puede usar un producto comercial.
El DataDirect es el negocio que realmente hace el
JDBC conductor de MS., entonces usted debera intentar su
conductor. Esto mostrar si el siguiente conductor de
los MS ser fijado.

>
> ************************************************** ********************
> Sent via Fuzzy Software @. http://www.fuzzysoftware.com/
> Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...

refreshRow not working

Hi
Can someone confirm that the refreshRow method on a ResultSet class does not
work and that it is a bug in the driver. I've tested the same code with
different drivers and it works ok... unless Microsoft has implemented the
functionallity different, can someone tell me what that is.....
Thanks
Carel
| Thread-Topic: refreshRow not working
| thread-index: AcUqLYcVVyNsCTdOQQKygCm51b/9Fg==
| X-WBNR-Posting-Host: 195.212.29.75
| From: "=?Utf-8?B?Q2FyZWwgZHUgdG9pdA==?="
<Careldutoit@.discussions.microsoft.com>
| Subject: refreshRow not working
| Date: Wed, 16 Mar 2005 05:39:07 -0800
| Lines: 8
| Message-ID: <D1611FB1-186E-45AD-B1F0-7F4B39D2178A@.microsoft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.sqlserver.jdbcdriver
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSF TNGXA03.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.sqlserver.jdbcdriver:6758
| X-Tomcat-NG: microsoft.public.sqlserver.jdbcdriver
|
| Hi
| Can someone confirm that the refreshRow method on a ResultSet class does
not
| work and that it is a bug in the driver. I've tested the same code with
| different drivers and it works ok... unless Microsoft has implemented
the
| functionallity different, can someone tell me what that is.....
|
| Thanks
| Carel
|
Hello,
The JDBC spec says that ResultSet.refreshRow() is not supported for
ResultSet objects that are type TYPE_FORWARD_ONLY, and does nothing for
those that are type TYPE_SCROLL_INSENSITIVE. This means that it can only
be used with TYPE_SCROLL_SENSITIVE. Since the Microsoft JDBC driver does
not support scroll sensitive ResultSets, the refreshRow() method is
behaving as expected.
Carb Simien, MCSE MCDBA MCAD
Microsoft Developer Support - Web Data
Please reply only to the newsgroups.
This posting is provided "AS IS" with no warranties, and confers no rights.
Are you secure? For information about the Strategic Technology Protection
Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.com/security.
sql

Wednesday, March 21, 2012

Referring to subreport fields from main (container) report....

All--
Is it possible, from within the context of a main report that contains
several subreports, to write code in the main report that refers to field
values within one or more of the contained subreports? (I would like to
display totals in the main report that are sums of quantities displayed in
several subreports.)
TIA,
mattyseltz in Queens, NYOn May 7, 1:24 pm, mattyseltz <mattyse...@.discussions.microsoft.com>
wrote:
> All--
> Is it possible, from within the context of a main report that contains
> several subreports, to write code in the main report that refers to field
> values within one or more of the contained subreports? (I would like to
> display totals in the main report that are sums of quantities displayed in
> several subreports.)
> TIA,
> mattyseltz in Queens, NY
The closest you can get to that is to include the same datasets in the
main report that exist in the subreports and use an expression similar
to the following:
=Sum(Fields!Quantity.Value, "SameDataSetAsUsedInSubReport")
Hope this helps.
Regards,
Enrique Martinez
Sr. Software Consultant|||Hi, Enrique,
Thanks for your reply. I see that you answered a similar question on
April 18, sorry to make you repeat yourself.
Best,
Matt
"EMartinez" wrote:
> On May 7, 1:24 pm, mattyseltz <mattyse...@.discussions.microsoft.com>
> wrote:
> > All--
> > Is it possible, from within the context of a main report that contains
> > several subreports, to write code in the main report that refers to field
> > values within one or more of the contained subreports? (I would like to
> > display totals in the main report that are sums of quantities displayed in
> > several subreports.)
> >
> > TIA,
> >
> > mattyseltz in Queens, NY
>
> The closest you can get to that is to include the same datasets in the
> main report that exist in the subreports and use an expression similar
> to the following:
> =Sum(Fields!Quantity.Value, "SameDataSetAsUsedInSubReport")
> Hope this helps.
> Regards,
> Enrique Martinez
> Sr. Software Consultant
>|||On May 8, 8:16 am, mattyseltz <mattyse...@.discussions.microsoft.com>
wrote:
> Hi, Enrique,
> Thanks for your reply. I see that you answered a similar question on
> April 18, sorry to make you repeat yourself.
> Best,
> Matt
> "EMartinez" wrote:
> > On May 7, 1:24 pm, mattyseltz <mattyse...@.discussions.microsoft.com>
> > wrote:
> > > All--
> > > Is it possible, from within the context of a main report that contains
> > > several subreports, to write code in the main report that refers to field
> > > values within one or more of the contained subreports? (I would like to
> > > display totals in the main report that are sums of quantities displayed in
> > > several subreports.)
> > > TIA,
> > > mattyseltz in Queens, NY
> > The closest you can get to that is to include the same datasets in the
> > main report that exist in the subreports and use an expression similar
> > to the following:
> > =Sum(Fields!Quantity.Value, "SameDataSetAsUsedInSubReport")
> > Hope this helps.
> > Regards,
> > Enrique Martinez
> > Sr. Software Consultant
You're welcome. No problem. Glad I could be of assistance.
Regards,
Enrique Martinez
Sr. Software Consultant

Referring to Sql connection string in web.config from code behind

Every time I move my project from my computer to the testing server I have to change the connection string references in the aspx side and in my code behind.

For the code behind I declared the SqlConnection string at the top of the code-behind page for both connection strings and comment out the one not in use. Obviously I then comment out the string not in use in the WebConfig as well.

Being superlatively lazy I always look for the easiest and quickest way to do most anything - connection strings included. Having to comment out strings twice brought rise to the question of whether I can refer to the connection string in the web.config file from the code-behind page. I'm sure it can be done, and I did a good amount of hunting around, but I couldn't find any examples of code that would do that.

Currently, as I said above, I have two connection strings declared at the top of my code-behind. Here's an example of one:

Private sqlConnAs New SqlConnection("Data Source=DATABASESERVER;Initial Catalog=DATABASE;User ID=USER;Password=PASSWORD")

Then, I just use sqlConn as usual in my binding without having to "dim" it in every sub:

sdaPersonnel =New SqlDataAdapter(strSqlPersonnel, sqlConn)

Then there's the SqlConnections set up by the wizard on the aspx side:

<asp:SqlDataSource ID="sqlDataSourcePayrollCompany" Runat="Server" ConnectionString="<%$ ConnectionStrings:DATABASECONNECTIONSTRING%>" ...>

And for the connection in the web.config:

<add name="DATABASECONNECTIONSTRING" connectionString="Data Source=DATABASESERVER;Initial Catalog=DATABASE;User ID=USER;Password=PASSWORD" providerName="System.Data.SqlClient" />

So, what would be the code in the code-behind page to refer to the connection string in the web.config file?

Thanks!

To refer to the connection string via code: ConfigurationManager.ConnectionStrings["<ConnectionStringName>"]|||

Hey, Stiletto, Thanks! That did the trick (or, at least, it got me on the right track). I wasn't exaclty sure how to actually add that to my connection string code, so I had to do some hunting and trying different syntax, but ended up with this working:

Private sqlConnAs New SqlConnection(ConfigurationManager.ConnectionStrings("DATABASECONNECTIONSTRING").ConnectionString)
Thanks again!

Tuesday, March 20, 2012

referencing report parameters in code

I'm trying to reference a report parameter in the code window:
Dim CompId As Integer
CompId = Parameters!CompanyId.Value
It gives me the error:
[BC30469] Reference to a non-shared member requires an object reference.
Any ideas (or alternatives) on how to resolve this? Thank you.TechnoSpyke,
The syntax to reference a report parameter has to be done by instantiating a
Reporting Object
For example:
Dim strParamName as string = â'ThisAStringLiteralâ'
Dim strParamValue as string = â'ThisAStringLiteralâ'
Dim Parameters(0) As Reporting.ParameterValue
Parameters(0) = New Reporting.ParameterValue
Parameters(0).Name = strParamName
Parameters(0).Value = strUSerID
For a better documentation, reference the SOAP API call in BOL
rwiethorn
"TechnoSpyke" wrote:
> I'm trying to reference a report parameter in the code window:
> Dim CompId As Integer
> CompId = Parameters!CompanyId.Value
> It gives me the error:
> [BC30469] Reference to a non-shared member requires an object reference.
> Any ideas (or alternatives) on how to resolve this? Thank you.
>
>|||Thanks for the reply, although I still have some problems.
What I wanted was to set a variable based on a report parameter (assuming
that this parameter has already a value), from within the report (code
window). The code below was taken from the BOL (Initializing Custom
Assembly Objects).
<Code>
Dim m_myClass As MyClass
Protected Overrides Sub OnInit()
m_myClass = new MyClass(User!Language, Paramters!Territory)
End Sub
</Code>
This is very similar to what I'm trying to do, yet I get a "[BC30469]
Reference to a non-shared member requires an object reference." everytime I
reference the Parameters.
"rwiethorn" <rwiethorn@.discussions.microsoft.com> wrote in message
news:BA485D54-C3F9-453A-8883-CADAD78570B5@.microsoft.com...
> TechnoSpyke,
> The syntax to reference a report parameter has to be done by instantiating
> a
> Reporting Object
> For example:
> Dim strParamName as string = "ThisAStringLiteral"
> Dim strParamValue as string = "ThisAStringLiteral"
> Dim Parameters(0) As Reporting.ParameterValue
> Parameters(0) = New Reporting.ParameterValue
> Parameters(0).Name = strParamName
> Parameters(0).Value = strUSerID
> For a better documentation, reference the SOAP API call in BOL
> rwiethorn
> "TechnoSpyke" wrote:
>> I'm trying to reference a report parameter in the code window:
>> Dim CompId As Integer
>> CompId = Parameters!CompanyId.Value
>> It gives me the error:
>> [BC30469] Reference to a non-shared member requires an object reference.
>> Any ideas (or alternatives) on how to resolve this? Thank you.
>>|||TechnoSpyke,
Were are you trying to get the value?
-in a custom assembly?
-in the code page of the report?
-in the expression builder of a control on a report?
If you're in a report, the report knows the name of the parameter. You
reference the param by name. So try to assign the value into a variable by
name.
I've not done that, but read about it. Search this newsgroup for params and
search BOL for param usage.
"TechnoSpyke" wrote:
> Thanks for the reply, although I still have some problems.
> What I wanted was to set a variable based on a report parameter (assuming
> that this parameter has already a value), from within the report (code
> window). The code below was taken from the BOL (Initializing Custom
> Assembly Objects).
> <Code>
> Dim m_myClass As MyClass
> Protected Overrides Sub OnInit()
> m_myClass = new MyClass(User!Language, Paramters!Territory)
> End Sub
> </Code>
> This is very similar to what I'm trying to do, yet I get a "[BC30469]
> Reference to a non-shared member requires an object reference." everytime I
> reference the Parameters.
>
> "rwiethorn" <rwiethorn@.discussions.microsoft.com> wrote in message
> news:BA485D54-C3F9-453A-8883-CADAD78570B5@.microsoft.com...
> > TechnoSpyke,
> > The syntax to reference a report parameter has to be done by instantiating
> > a
> > Reporting Object
> >
> > For example:
> > Dim strParamName as string = "ThisAStringLiteral"
> > Dim strParamValue as string = "ThisAStringLiteral"
> > Dim Parameters(0) As Reporting.ParameterValue
> >
> > Parameters(0) = New Reporting.ParameterValue
> > Parameters(0).Name = strParamName
> > Parameters(0).Value = strUSerID
> >
> > For a better documentation, reference the SOAP API call in BOL
> >
> > rwiethorn
> >
> > "TechnoSpyke" wrote:
> >
> >> I'm trying to reference a report parameter in the code window:
> >>
> >> Dim CompId As Integer
> >> CompId = Parameters!CompanyId.Value
> >>
> >> It gives me the error:
> >> [BC30469] Reference to a non-shared member requires an object reference.
> >>
> >> Any ideas (or alternatives) on how to resolve this? Thank you.
> >>
> >>
> >>
>
>|||I am trying to get the parameter value from the code page of the report. My
code looks like this (modified for this purpose):
Protected Overrides Sub OnInit()
Dim compId As Integer
'following code returns error [BC30469]
compId = Parameters!CompanyId
'following code still returns error [BC30469]
compId = Parameters!CompanyId.Value
'following code doesn't return an error, although not sure if I have the
correct value
compId = Report.Parameters("CompanyId").Value
End Sub
"rwiethorn" <rwiethorn@.discussions.microsoft.com> wrote in message
news:A5C1CEDC-1751-48FA-936A-ADEF01259F22@.microsoft.com...
> TechnoSpyke,
> Were are you trying to get the value?
> -in a custom assembly?
> -in the code page of the report?
> -in the expression builder of a control on a report?
> If you're in a report, the report knows the name of the parameter. You
> reference the param by name. So try to assign the value into a variable by
> name.
> I've not done that, but read about it. Search this newsgroup for params
> and
> search BOL for param usage.
> "TechnoSpyke" wrote:
>> Thanks for the reply, although I still have some problems.
>> What I wanted was to set a variable based on a report parameter (assuming
>> that this parameter has already a value), from within the report (code
>> window). The code below was taken from the BOL (Initializing Custom
>> Assembly Objects).
>> <Code>
>> Dim m_myClass As MyClass
>> Protected Overrides Sub OnInit()
>> m_myClass = new MyClass(User!Language, Paramters!Territory)
>> End Sub
>> </Code>
>> This is very similar to what I'm trying to do, yet I get a "[BC30469]
>> Reference to a non-shared member requires an object reference." everytime
>> I
>> reference the Parameters.
>>
>> "rwiethorn" <rwiethorn@.discussions.microsoft.com> wrote in message
>> news:BA485D54-C3F9-453A-8883-CADAD78570B5@.microsoft.com...
>> > TechnoSpyke,
>> > The syntax to reference a report parameter has to be done by
>> > instantiating
>> > a
>> > Reporting Object
>> >
>> > For example:
>> > Dim strParamName as string = "ThisAStringLiteral"
>> > Dim strParamValue as string = "ThisAStringLiteral"
>> > Dim Parameters(0) As Reporting.ParameterValue
>> >
>> > Parameters(0) = New Reporting.ParameterValue
>> > Parameters(0).Name = strParamName
>> > Parameters(0).Value = strUSerID
>> >
>> > For a better documentation, reference the SOAP API call in BOL
>> >
>> > rwiethorn
>> >
>> > "TechnoSpyke" wrote:
>> >
>> >> I'm trying to reference a report parameter in the code window:
>> >>
>> >> Dim CompId As Integer
>> >> CompId = Parameters!CompanyId.Value
>> >>
>> >> It gives me the error:
>> >> [BC30469] Reference to a non-shared member requires an object
>> >> reference.
>> >>
>> >> Any ideas (or alternatives) on how to resolve this? Thank you.
>> >>
>> >>
>> >>
>>

Referencing Parameters in Report Code

I'm trying to refer to a report parameter in my Code block from the Report
Properties page. But it keeps giving me an error that says, "Reference to a
non-shared member requires an object reference." I'm refering the parameter
as Parameters!pBusiness.Label.
Any ideas about how I can see my parameters within the Code block of the
Report itself?you must pass the values in ie
code.dosomething(Param1!value, Param2.value)
--
Wayne Snyder MCDBA, SQL Server MVP
Mariner, Charlotte, NC
(Please respond only to the newsgroup.)
I support the Professional Association for SQL Server ( PASS) and it's
community of SQL Professionals.
"SteveCole63" <SteveCole63@.discussions.microsoft.com> wrote in message
news:C23B3F0A-A341-47AD-A678-6A6DFD9EE114@.microsoft.com...
> I'm trying to refer to a report parameter in my Code block from the Report
> Properties page. But it keeps giving me an error that says, "Reference to
a
> non-shared member requires an object reference." I'm refering the
parameter
> as Parameters!pBusiness.Label.
> Any ideas about how I can see my parameters within the Code block of the
> Report itself?|||Actually Wayne, you can refer to parameters (I discovered after I posted) as
Report.Parameters!pBusiness.Label.
Thanks for the reply!
"Wayne Snyder" wrote:
> you must pass the values in ie
> code.dosomething(Param1!value, Param2.value)
> --
> Wayne Snyder MCDBA, SQL Server MVP
> Mariner, Charlotte, NC
> (Please respond only to the newsgroup.)
> I support the Professional Association for SQL Server ( PASS) and it's
> community of SQL Professionals.
> "SteveCole63" <SteveCole63@.discussions.microsoft.com> wrote in message
> news:C23B3F0A-A341-47AD-A678-6A6DFD9EE114@.microsoft.com...
> > I'm trying to refer to a report parameter in my Code block from the Report
> > Properties page. But it keeps giving me an error that says, "Reference to
> a
> > non-shared member requires an object reference." I'm refering the
> parameter
> > as Parameters!pBusiness.Label.
> >
> > Any ideas about how I can see my parameters within the Code block of the
> > Report itself?
>
>

Referencing Multi-value parameters in SQL code.

Hi everyone,

I have a report with 2 parameters - Account Manager and Company.

They are both populated from SQL Queries.

The Company query uses the value of the Account Manager parameter in the Where clause so that if an Account Manager is slected only the companies they are in charge of are displayed in the Company parameter.

My Select statement for the Company parameter list is as follows:

SELECT C.Company_Name
FROM Company C INNER JOIN
Employee E ON C.Account_Manager_Id = E.Employee_Id
WHERE (C.Type LIKE ('Customer%') OR C.Type = ('Partner - Customer'))
AND (E._Full_Name = @.Account_Manager)

How can I get this to work if I change the Account Manager parameter to be a Multi-value parameter?

I have tried replacing the "E._Full_Name = @.Account_Manager" with "E._Full_Name IN @.Account_Manager" but this does not work - is there another way to get this working?

Thanks,

Paul.

The IN clause requires the use of brackets.

Try E._Full_Name IN (@.Account_Manager)

|||That did the trick, thanks!

referencing inserted and deleted tables with sp_executeSql

Hi everyone. Thanks in advance to anyone who might be able to shed some light on this situation.

I have a trigger in which the following SQL code exists.

SET @.tempInserted = N'SET @.dummy = (SELECT '+@.cftColumnName+' FROM INSERTED)'
EXEC sp_executeSQL @.tempInserted, N'@.dummy varchar(255) output', @.dummy=@.tempAddress output

When the trigger executes I receive the following error message...

Server: Msg 208, Level 16, State 1, Line 1
Invalid object name 'INSERTED'.

My question is, is it possible to in some way reference the INSERTED and DELETED tables using sp_executeSQL?I was able to replicate your problem:
-- Set Option Value
-- -------- ----
-- textsize 64512
-- language us_english
-- dateformat mdy
-- datefirst 7
-- arithabort SET
-- nocount SET
-- remote_proc_transactions SET
-- ansi_null_dflt_on SET
-- ansi_warnings SET
-- ansi_padding SET
-- ansi_nulls SET
-- concat_null_yields_null SET

create table #Tmp(f1 int, f2 char(1))
go
create trigger TmpTrigger on Tmp
FOR DELETE, INSERT, UPDATE
AS
BEGIN
declare @.tempInserted nvarchar(100)
, @.cftColumnName nvarchar(100)
, @.tempAddress nvarchar(100)
set @.cftColumnName = 'f2'
SET @.tempInserted = N'SELECT @.dummy = ' + @.cftColumnName + ' FROM inserted'
SET @.tempInserted = N'select * From #Tmp'
EXEC sp_executeSQL @.tempInserted, N'@.dummy varchar(255) output', @.dummy=@.tempAddress output
select @.tempAddress
END
go
insert into #Tmp values(2,'B')
insert into Tmp values(1,'A')
select * From Tmp
go
drop table #Tmp
drop table Tmp
go

The only thing I can figure out is that since inserted and deleted are special temp tables they are not available to the new process created during the execution of sp_executeSQL.|||Thanks Paul. I ended up taking a different approach that essentially enabled me to achieve what I was attempting to do. Instead of directly referencing the INSERTED and DELETED tables I first create another set of temp tables to which I copy all the records from INSERTED and DELETED. I can then make a reference to these temporary tables during the execution of sp_executeSQL.

Not perfect but it works =).|||A workable solution is better than nothing working! You can always go back and change your code once everything runs end to end.

referencing fields in the code window

Hi, how do I reference a report field in a custom function which is written
in the code window (Report Properties/code tab)? i.e.
Function Something
If Fields!FIELD1_Company.Value = Nothing Then
Return ""
End If
End Function
This example will not work but it's similar to my needs
Thanks
NPSend the field value as a parameter to your function. i.e. re-write the
function as:
Function SomeFunction(byVal MyFieldValue as datatype) as datatype
if MyFieldValue is nothing
...
return ...
End Function
In your report expression, just call the function:
=Code.SomeFunction(Fields!MyField.Value)
Charles Kangai, MCT, MCDBA
"slk55guy" wrote:
> Hi, how do I reference a report field in a custom function which is written
> in the code window (Report Properties/code tab)? i.e.
> Function Something
> If Fields!FIELD1_Company.Value = Nothing Then
> Return ""
> End If
> End Function
> This example will not work but it's similar to my needs
> Thanks
> NP
>|||Thanks Charles, by the way how are you? I was on one of your DTS courses a
couple of years ago in the city. Small world eh?
I think this will work but there is another post (converting crystal code) I
put up here and basically I'm trying to get the same functionality as I would
in a Crystal function.
Happy Christmas
NP
"Charles Kangai" wrote:
> Send the field value as a parameter to your function. i.e. re-write the
> function as:
> Function SomeFunction(byVal MyFieldValue as datatype) as datatype
> if MyFieldValue is nothing
> ...
> return ...
> End Function
> In your report expression, just call the function:
> =Code.SomeFunction(Fields!MyField.Value)
> Charles Kangai, MCT, MCDBA
>
> "slk55guy" wrote:
> > Hi, how do I reference a report field in a custom function which is written
> > in the code window (Report Properties/code tab)? i.e.
> >
> > Function Something
> > If Fields!FIELD1_Company.Value = Nothing Then
> > Return ""
> > End If
> > End Function
> >
> > This example will not work but it's similar to my needs
> >
> > Thanks
> >
> > NP
> >|||Hi,
It should work. I am using something similar myself.
I did a demonstration and some conversations for a customer earlier this
week. The developers are all Crystal users, and they were so impressed with
Reporting Services that they are going to migrate all their sites in UK,
Italy, USA, and Denmark to RS within the next few weeks.
Great to come across you again - we will be running a Reporting Services
course from the end of Feb. I am the author. Check with Learning Tree.
Merry Christmas!
Charles
"slk55guy" wrote:
> Thanks Charles, by the way how are you? I was on one of your DTS courses a
> couple of years ago in the city. Small world eh?
> I think this will work but there is another post (converting crystal code) I
> put up here and basically I'm trying to get the same functionality as I would
> in a Crystal function.
> Happy Christmas
> NP
> "Charles Kangai" wrote:
> > Send the field value as a parameter to your function. i.e. re-write the
> > function as:
> >
> > Function SomeFunction(byVal MyFieldValue as datatype) as datatype
> > if MyFieldValue is nothing
> > ...
> > return ...
> > End Function
> >
> > In your report expression, just call the function:
> > =Code.SomeFunction(Fields!MyField.Value)
> >
> > Charles Kangai, MCT, MCDBA
> >
> >
> > "slk55guy" wrote:
> >
> > > Hi, how do I reference a report field in a custom function which is written
> > > in the code window (Report Properties/code tab)? i.e.
> > >
> > > Function Something
> > > If Fields!FIELD1_Company.Value = Nothing Then
> > > Return ""
> > > End If
> > > End Function
> > >
> > > This example will not work but it's similar to my needs
> > >
> > > Thanks
> > >
> > > NP
> > >

referencing fields in code

I'd like the user to decide how to group the report. For this I have the
parameter KStar and a piece of custom code.
Under 'Edit group' I use the expression:
=Code.GetGroups(Parameters!KStar.Value )
In the code window I have a function that starts like this:
Public Shared Function GetGroups (Byref KStar As integer)
Select (KStar)
Case 1
Return(Fields!K1.Value)
Case 2
Return(Fields!K2.Value)
It gives me the error:
[BC30469] Reference to a non-shared member requires an object reference.
How do I solve this? I am obviously very new to Reporting Services and I
would appreciate any help.
Thanks!First try replacing Fields!KStar.Value by Report.Fields!KStar.Value, if that
does not work you will have to pass the field values in as a parameter
--
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"maple" <maple@.discussions.microsoft.com> wrote in message
news:E87A2353-646F-4FA9-AA2D-367BCB91348D@.microsoft.com...
> I'd like the user to decide how to group the report. For this I have the
> parameter KStar and a piece of custom code.
> Under 'Edit group' I use the expression:
> =Code.GetGroups(Parameters!KStar.Value )
> In the code window I have a function that starts like this:
> Public Shared Function GetGroups (Byref KStar As integer)
> Select (KStar)
> Case 1
> Return(Fields!K1.Value)
> Case 2
> Return(Fields!K2.Value)
> It gives me the error:
> [BC30469] Reference to a non-shared member requires an object reference.
> How do I solve this? I am obviously very new to Reporting Services and I
> would appreciate any help.
> Thanks!
>

Referencing field by name in code

I have a field (Fields!myfield) that I would like to pass in the name as two parts(Code.GetField("my","field") and dynamically return either a reference to myfield or the value itself.

I'm getting Reference to a shared field requires a shared reference error when I try to return Fields!Myfield.Value from the function.

I would like the ability to pass in the name of a field to a function and return the actual field name (or value of the field) to the report. Any ideas?

That was easy. Fields("my" & code.getname("test")).Value seems to work well.

Referencing destination table in INSERT SELECT statement

Hi
I hava a following piece of code:
CREATE TABLE #s(s varchar)
INSERT INTO #s VALUES ('a')
INSERT INTO #s VALUES ('b')
INSERT INTO #s VALUES ('c')
CREATE TABLE #d(s varchar, d int)
INSERT INTO #d SELECT s, ISNULL((SELECT MAX(d) + 1 FROM #d), 0) FROM #s
SELECT d FROM #d
DROP TABLE #d
DROP TABLE #s
As you can see I'm trying to copy data from the source table to the
destination one, and while doing so, assign each row a subsequent
number (d) starting from 0.
I assumed, that the SELECT clause will be run for each inserted row -
however - when I run this code as the result I receive only zeros in
the d column for all rows.
I've already tried WITH (NOLOCK/ROWLOCK) clauses to no avail.
Is there any way to get this query running?
Thanks
SzymonHi
CREATE TABLE #s(s varchar)
INSERT INTO #s VALUES ('a')
INSERT INTO #s VALUES ('b')
INSERT INTO #s VALUES ('c')
CREATE TABLE #d(s varchar, d int)
INSERT INTO #d SELECT s,(select count(*) from #s s where s.s<=#s.s) FROM
#s
SELECT d FROM #d
DROP TABLE #d
DROP TABLE #s
<joozeq@.gmail.com> wrote in message
news:1163408290.886457.14770@.h54g2000cwb.googlegroups.com...
> Hi
> I hava a following piece of code:
> CREATE TABLE #s(s varchar)
> INSERT INTO #s VALUES ('a')
> INSERT INTO #s VALUES ('b')
> INSERT INTO #s VALUES ('c')
> CREATE TABLE #d(s varchar, d int)
> INSERT INTO #d SELECT s, ISNULL((SELECT MAX(d) + 1 FROM #d), 0) FROM #s
> SELECT d FROM #d
> DROP TABLE #d
> DROP TABLE #s
> As you can see I'm trying to copy data from the source table to the
> destination one, and while doing so, assign each row a subsequent
> number (d) starting from 0.
> I assumed, that the SELECT clause will be run for each inserted row -
> however - when I run this code as the result I receive only zeros in
> the d column for all rows.
> I've already tried WITH (NOLOCK/ROWLOCK) clauses to no avail.
> Is there any way to get this query running?
> Thanks
> Szymon
>|||Hi,
You can try the following query:
CREATE TABLE #s(s varchar)
INSERT INTO #s VALUES ('a')
INSERT INTO #s VALUES ('b')
INSERT INTO #s VALUES ('c')
Without creating the #d table you can create and insert the data of #s table
in #d by the following query:
SELECT s, ROWID=IDENTITY(int,0,1) into #d from #s
Regards
Swaprakash
"joozeq@.gmail.com" wrote:
> Hi
> I hava a following piece of code:
> CREATE TABLE #s(s varchar)
> INSERT INTO #s VALUES ('a')
> INSERT INTO #s VALUES ('b')
> INSERT INTO #s VALUES ('c')
> CREATE TABLE #d(s varchar, d int)
> INSERT INTO #d SELECT s, ISNULL((SELECT MAX(d) + 1 FROM #d), 0) FROM #s
> SELECT d FROM #d
> DROP TABLE #d
> DROP TABLE #s
> As you can see I'm trying to copy data from the source table to the
> destination one, and while doing so, assign each row a subsequent
> number (d) starting from 0.
> I assumed, that the SELECT clause will be run for each inserted row -
> however - when I run this code as the result I receive only zeros in
> the d column for all rows.
> I've already tried WITH (NOLOCK/ROWLOCK) clauses to no avail.
> Is there any way to get this query running?
> Thanks
> Szymon
>|||joozeq@.gmail.com wrote:
> Hi
> I hava a following piece of code:
> CREATE TABLE #s(s varchar)
> INSERT INTO #s VALUES ('a')
> INSERT INTO #s VALUES ('b')
> INSERT INTO #s VALUES ('c')
> CREATE TABLE #d(s varchar, d int)
> INSERT INTO #d SELECT s, ISNULL((SELECT MAX(d) + 1 FROM #d), 0) FROM #s
> SELECT d FROM #d
> DROP TABLE #d
> DROP TABLE #s
> As you can see I'm trying to copy data from the source table to the
> destination one, and while doing so, assign each row a subsequent
> number (d) starting from 0.
> I assumed, that the SELECT clause will be run for each inserted row -
> however - when I run this code as the result I receive only zeros in
> the d column for all rows.
> I've already tried WITH (NOLOCK/ROWLOCK) clauses to no avail.
> Is there any way to get this query running?
> Thanks
> Szymon
>
Make the column "d" an identity column, and let SQL assign the
incremental value:
CREATE TABLE #s(s varchar)
INSERT INTO #s VALUES ('a')
INSERT INTO #s VALUES ('b')
INSERT INTO #s VALUES ('c')
CREATE TABLE #d(s varchar, d int identity(0,1))
INSERT INTO #d SELECT s FROM #s
SELECT d FROM #d
DROP TABLE #d
DROP TABLE #s
Tracy McKibben
MCDBA
http://www.realsqlguy.com|||This is a multi-part message in MIME format.
--=_NextPart_000_00FF_01C706FC.3EEA82B0
Content-Type: text/plain;
charset="iso-8859-2"
Content-Transfer-Encoding: quoted-printable
Why not add an IDENTITY column to table #s?
CREATE TABLE #s
( RowID int IDENTITY,
s varchar(20)
)
INSERT INTO #s VALUES ('a')
INSERT INTO #s VALUES ('b')
INSERT INTO #s VALUES ('c')
-- Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience. Most experience comes from bad judgment. - Anonymous
You can't help someone get up a hill without getting a little closer to =the top yourself.
- H. Norman Schwarzkopf
<joozeq@.gmail.com> wrote in message =news:1163408290.886457.14770@.h54g2000cwb.googlegroups.com...
> Hi
> > I hava a following piece of code:
> > CREATE TABLE #s(s varchar)
> INSERT INTO #s VALUES ('a')
> INSERT INTO #s VALUES ('b')
> INSERT INTO #s VALUES ('c')
> > CREATE TABLE #d(s varchar, d int)
> > INSERT INTO #d SELECT s, ISNULL((SELECT MAX(d) + 1 FROM #d), 0) FROM =#s
> > SELECT d FROM #d
> DROP TABLE #d
> DROP TABLE #s
> > As you can see I'm trying to copy data from the source table to the
> destination one, and while doing so, assign each row a subsequent
> number (d) starting from 0.
> > I assumed, that the SELECT clause will be run for each inserted row -
> however - when I run this code as the result I receive only zeros in
> the d column for all rows.
> > I've already tried WITH (NOLOCK/ROWLOCK) clauses to no avail.
> > Is there any way to get this query running? > > Thanks
> Szymon
>
--=_NextPart_000_00FF_01C706FC.3EEA82B0
Content-Type: text/html;
charset="iso-8859-2"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&

Why not add an IDENTITY column to table =#s?
CREATE TABLE #s =( RowID int IDENTITY, s varchar(20) )
INSERT INTO #s VALUES =('a')INSERT INTO #s VALUES ('b')INSERT INTO #s VALUES ('c')
-- Arnie Rowland, =Ph.D.Westwood Consulting, Inc
Most good judgment comes from =experience. Most experience comes from bad judgment. - Anonymous
You can't help someone get up a hill =without getting a little closer to the top yourself.- H. Norman Schwarzkopf
wrote in message news:1163408290.886457.14770@.h54g2000cwb.googlegroups.com=...> =Hi> > I hava a following piece of code:> > CREATE TABLE =#s(s varchar)> INSERT INTO #s VALUES ('a')> INSERT INTO #s =VALUES ('b')> INSERT INTO #s VALUES ('c')> > CREATE TABLE =#d(s varchar, d int)> > INSERT INTO #d SELECT s, ISNULL((SELECT =MAX(d) + 1 FROM #d), 0) FROM #s> > SELECT d FROM #d> DROP =TABLE #d> DROP TABLE #s> > As you can see I'm trying to =copy data from the source table to the> destination one, and while doing =so, assign each row a subsequent> number (d) starting from 0.> => I assumed, that the SELECT clause will be run for each inserted row =-> however - when I run this code as the result I receive only zeros =in> the d column for all rows.> > I've already tried WITH =(NOLOCK/ROWLOCK) clauses to no avail.> > Is there any way to get this query =running? > > Thanks> =Szymon>

--=_NextPart_000_00FF_01C706FC.3EEA82B0--|||I can't use IDENTITY because the problem is a bit more complex that I
might have described it at the beginning of this thread. Here's a bit
less abstract story:
I have a table with about 150 000 rows, which holds geographical
coordinates of a certain GPS receiver (placed in a vehicle) in a
certain moment. The table structure is as follows:
IdCoordinates int IDENTITY PRIMARY KEY
CarId nvarchar(50)
Longitude float
Latitude float
Date datetime (indexed)
Quite often I need to derive the speed of a car throughout a day,
basing on this data. This involves finding for each row in a day the
preceeding one (to calculate the distance driven and time elapsed
between the two). The simplest way is to construct a query basing on
NOT EXISTS operator but this prooves itself to be terribly slow.
So I figured out I'd add to the table additional column, SequenceNo
int, which for a certain row would hold number of all rows gathered
from the same car with dates lesser the the row's date. This makes the
query both simple and efficient.
However - with 150 000 rows (and very soon I expect it to be over 500
000) - adding this column requires first to properly update the
SequenceNo field for all rows.
First I thought that simple UPDATE Coordinates SET SequenceNo = SELECT
MAX ... would do, but this query sets all values to 1 (providing all
the values are NULL at the beginning) - apparently some row/table
locking issue (is it?).
Then I tried to create something like Oracle's sequence that would
return next sequence number for the given car id, but this requires one
of the following:
- SELECT trigger (I'd create it on a Sequence(CarId, NextSequenceNo)
table )
- UDF (so I can use it in the SET clause OF the UPDATE query) that can
issue DML statements (so it can remember current seqence number for a
certain car and return the next one)
- SP (they can ofcourse use DML) that can return value and be used in a
SET clause
AFAIK none of these exist in SQL Server 2000 (though there's a hack
somewhere on the web to create a SELECT trigger). So now I've ended up
with a SP that simply reads all data from the Coordinates table with a
cursor (the data being read must be ordered by date), fetches next
available SequenceNo from a temp table and inserts it to another temp
table with the SequenceNo field set properly (I know that updating the
source table would be more appropriate here but it's very slow).
It's dirty, slow and resource consuming - my best solution so far is to
use an update curosor and update the row in place with WHERE CURRENT OF
clause - but apparently SQL Server 2000 doesn't support curors with
ORDER BY and FOR UPDATE clauses put together, so this works only for
SQL Server 2005.
I'd appreciate any suggestions on how to solve this nicely.
Szymon
Arnie Rowland napisal(a):
> Why not add an IDENTITY column to table #s?
> CREATE TABLE #s
> ( RowID int IDENTITY,
> s varchar(20)
> )
> INSERT INTO #s VALUES ('a')
> INSERT INTO #s VALUES ('b')
> INSERT INTO #s VALUES ('c')
> --
> Arnie Rowland, Ph.D.
> Westwood Consulting, Inc
> Most good judgment comes from experience.
> Most experience comes from bad judgment.
> - Anonymous
> You can't help someone get up a hill without getting a little closer to the top yourself.
> - H. Norman Schwarzkopf
>|||Sorry - I CAN use ordered update cursors with SQL 2000 - I simply
forgot to add PK to the table and got misleading error message.
If anyone knows a better solution to the problem then the one with
update cursor I'd appreciate suggestions.
Szymon
joozeq@.gmail.com napisal(a):
> I can't use IDENTITY because the problem is a bit more complex that I
> might have described it at the beginning of this thread. Here's a bit
> less abstract story:
> I have a table with about 150 000 rows, which holds geographical
> coordinates of a certain GPS receiver (placed in a vehicle) in a
> certain moment. The table structure is as follows:
> IdCoordinates int IDENTITY PRIMARY KEY
> CarId nvarchar(50)
> Longitude float
> Latitude float
> Date datetime (indexed)
> Quite often I need to derive the speed of a car throughout a day,
> basing on this data. This involves finding for each row in a day the
> preceeding one (to calculate the distance driven and time elapsed
> between the two). The simplest way is to construct a query basing on
> NOT EXISTS operator but this prooves itself to be terribly slow.
> So I figured out I'd add to the table additional column, SequenceNo
> int, which for a certain row would hold number of all rows gathered
> from the same car with dates lesser the the row's date. This makes the
> query both simple and efficient.
> However - with 150 000 rows (and very soon I expect it to be over 500
> 000) - adding this column requires first to properly update the
> SequenceNo field for all rows.
> First I thought that simple UPDATE Coordinates SET SequenceNo = SELECT
> MAX ... would do, but this query sets all values to 1 (providing all
> the values are NULL at the beginning) - apparently some row/table
> locking issue (is it?).
> Then I tried to create something like Oracle's sequence that would
> return next sequence number for the given car id, but this requires one
> of the following:
> - SELECT trigger (I'd create it on a Sequence(CarId, NextSequenceNo)
> table )
> - UDF (so I can use it in the SET clause OF the UPDATE query) that can
> issue DML statements (so it can remember current seqence number for a
> certain car and return the next one)
> - SP (they can ofcourse use DML) that can return value and be used in a
> SET clause
> AFAIK none of these exist in SQL Server 2000 (though there's a hack
> somewhere on the web to create a SELECT trigger). So now I've ended up
> with a SP that simply reads all data from the Coordinates table with a
> cursor (the data being read must be ordered by date), fetches next
> available SequenceNo from a temp table and inserts it to another temp
> table with the SequenceNo field set properly (I know that updating the
> source table would be more appropriate here but it's very slow).
> It's dirty, slow and resource consuming - my best solution so far is to
> use an update curosor and update the row in place with WHERE CURRENT OF
> clause - but apparently SQL Server 2000 doesn't support curors with
> ORDER BY and FOR UPDATE clauses put together, so this works only for
> SQL Server 2005.
> I'd appreciate any suggestions on how to solve this nicely.
> Szymon
> Arnie Rowland napisal(a):
> > Why not add an IDENTITY column to table #s?
> >
> > CREATE TABLE #s
> > ( RowID int IDENTITY,
> > s varchar(20)
> > )
> >
> > INSERT INTO #s VALUES ('a')
> > INSERT INTO #s VALUES ('b')
> > INSERT INTO #s VALUES ('c')
> >
> > --
> > Arnie Rowland, Ph.D.
> > Westwood Consulting, Inc
> >
> > Most good judgment comes from experience.
> > Most experience comes from bad judgment.
> > - Anonymous
> >
> > You can't help someone get up a hill without getting a little closer to the top yourself.
> > - H. Norman Schwarzkopf
> >
> >|||Perhaps one of these articles may help:
Row Number (or Rank) from a SELECT Transact-SQL statement (includes Paging)
http://support.microsoft.com/default.aspx?scid=kb;en-us;186133
http://sqljunkies.com/WebLog/amachanic/archive/2004/11/03/4945.aspx
http://www.projectdmx.com/tsql/ranking.aspx
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
You can't help someone get up a hill without getting a little closer to the
top yourself.
- H. Norman Schwarzkopf
<joozeq@.gmail.com> wrote in message
news:1164136011.455451.90600@.b28g2000cwb.googlegroups.com...
>I can't use IDENTITY because the problem is a bit more complex that I
> might have described it at the beginning of this thread. Here's a bit
> less abstract story:
> I have a table with about 150 000 rows, which holds geographical
> coordinates of a certain GPS receiver (placed in a vehicle) in a
> certain moment. The table structure is as follows:
> IdCoordinates int IDENTITY PRIMARY KEY
> CarId nvarchar(50)
> Longitude float
> Latitude float
> Date datetime (indexed)
> Quite often I need to derive the speed of a car throughout a day,
> basing on this data. This involves finding for each row in a day the
> preceeding one (to calculate the distance driven and time elapsed
> between the two). The simplest way is to construct a query basing on
> NOT EXISTS operator but this prooves itself to be terribly slow.
> So I figured out I'd add to the table additional column, SequenceNo
> int, which for a certain row would hold number of all rows gathered
> from the same car with dates lesser the the row's date. This makes the
> query both simple and efficient.
> However - with 150 000 rows (and very soon I expect it to be over 500
> 000) - adding this column requires first to properly update the
> SequenceNo field for all rows.
> First I thought that simple UPDATE Coordinates SET SequenceNo = SELECT
> MAX ... would do, but this query sets all values to 1 (providing all
> the values are NULL at the beginning) - apparently some row/table
> locking issue (is it?).
> Then I tried to create something like Oracle's sequence that would
> return next sequence number for the given car id, but this requires one
> of the following:
> - SELECT trigger (I'd create it on a Sequence(CarId, NextSequenceNo)
> table )
> - UDF (so I can use it in the SET clause OF the UPDATE query) that can
> issue DML statements (so it can remember current seqence number for a
> certain car and return the next one)
> - SP (they can ofcourse use DML) that can return value and be used in a
> SET clause
> AFAIK none of these exist in SQL Server 2000 (though there's a hack
> somewhere on the web to create a SELECT trigger). So now I've ended up
> with a SP that simply reads all data from the Coordinates table with a
> cursor (the data being read must be ordered by date), fetches next
> available SequenceNo from a temp table and inserts it to another temp
> table with the SequenceNo field set properly (I know that updating the
> source table would be more appropriate here but it's very slow).
> It's dirty, slow and resource consuming - my best solution so far is to
> use an update curosor and update the row in place with WHERE CURRENT OF
> clause - but apparently SQL Server 2000 doesn't support curors with
> ORDER BY and FOR UPDATE clauses put together, so this works only for
> SQL Server 2005.
> I'd appreciate any suggestions on how to solve this nicely.
> Szymon
> Arnie Rowland napisal(a):
>> Why not add an IDENTITY column to table #s?
>> CREATE TABLE #s
>> ( RowID int IDENTITY,
>> s varchar(20)
>> )
>> INSERT INTO #s VALUES ('a')
>> INSERT INTO #s VALUES ('b')
>> INSERT INTO #s VALUES ('c')
>> --
>> Arnie Rowland, Ph.D.
>> Westwood Consulting, Inc
>> Most good judgment comes from experience.
>> Most experience comes from bad judgment.
>> - Anonymous
>> You can't help someone get up a hill without getting a little closer to
>> the top yourself.
>> - H. Norman Schwarzkopf
>>
>

Referencing and renaming tables..

help how to reference n rename table..

is it possible by code?

renaming..

There are two ways to rename a table. The first and easier way is with the use of SQL Server Enterprise Manager. Simply go to the database where the table is located and right-click on the table you want to rename. Select "Rename" from the context menu and change the name. After entering the new name, the following message will be displayed:

Changing the name of the table will cause stored procedures, views, or triggers that reference the table tobecome invalid. Are you sure you want to rename the table?

If you are sure that there are no stored procedures, views or triggers that reference the table, then click on the Yes button. If you are not sure if the table is being reference by any other object, click on the View Dependencies button to see the objects that depend on the table as well as the objects that the table depends on. You are more concerned on the objects that depend on the table because you have to modify those objects to reflect the new name of the table.

The second way to rename a table is with the use of sp_rename system stored procedure. The sp_rename system stored procedure changes the name of a user-created object, such as a table, column or user-defined type, in the current database

sp_rename [ @.objname = ] 'Object Name', [ @.newname = ] 'New Name' [ , [ @.objtype = ] 'Object Type' ]

The 'Object Name' is the current name of the user object (table, view, column, stored procedure, trigger, default, database, object, or rule) or data type. The 'New Name' is the new name for the specified object. The 'Object Name' is the type of object being renamed. Since we are only concerned of renaming a table, this optional parameter can be ignored.

Here's how to rename a table called [dbo].[Clients] to [dbo].[Customers]:

EXECUTE sp_rename '[dbo].[Clients]', 'Customers'

If there's no object with the name of Customers that exist in the current database, then the table will be renamed to [dbo].[Customers] and the following message will be displayed:

Caution: Changing any part of an object name could break scripts and stored procedures. The object was renamed to 'Customers'.

This is just a warning message informing you that you have to modify any scripts or stored procedures that you may have that references the table using its previous name.

If an object already exists with the name that you specified, you will encounter the following error message:

Server: Msg 15335, Level 11, State 1, Procedure sp_rename, Line 342 Error: The @.newname value 'Customers' is already in use as a object name and would cause a duplicate that is not permitted.

Just make sure that the new name that you are assigning to the table is not yet used by any object (not just by tables but also by other objects such as views) to avoid getting this error.

|||

referencing ...

To reference a table from another database in the same server, simply prefix the table with the database name. In other words, use the 3-part naming convention of the table.

To illustrate, to select from the [dbo].[Authors] table in the pubs database from the Northwind database, the SELECT statement will be as follows:

SELECT * FROM [pubs].[dbo].[Authors]|||the rename option isnt available when i roight click the table|||

Hello!

I have problem with sp_rename:

I do us follows:

EXECUTE sp_rename N'[emma].[dim_model_tmp]', N'[emma].[dim_model_tmp2]'

The table [emma].[dim_model_tmp] disappears but and I cannot find [emma].[dim_model_tmp2].

Tried to create a new [emma].[dim_model_tmp] and rename it again. But get the following error:

Msg 15335, Level 11, State 1, Procedure sp_rename, Line 402

Error: The new name '[emma].[dim_model_tmp2]' is already in use as a object name and would cause a duplicate that is not permitted.

Tried to find [emma].[dim_model_tmp2]:

select * from SYSOBJECTS where upper(name) = upper('dim_model_tmp2')

select * from INFORMATION_SCHEMA.TABLES where upper(table_name) = 'DIM_MODEL_TMP2'

But no hit!

I have also tried:

EXECUTE sp_rename N'[did_stage].[emma].[dim_model_tmp]', N'[did_stage].[emma].[dim_model_tmp2]'

But this has the same effect.

Can anyone explain where my table gone and how to rename it right?

Best regards,

Tina

|||

Hello!

The sp_rename should look like this:

EXECUTE sp_rename N'emma.dim_model_tmp', N'dim_model_tmp2'

The schema name shall not be on the new table name. Don’t use the "[" will become part of the table name.

To find the tables use like in the select statements:

select * from SYSOBJECTS where upper(name) like upper('%dim_model%')

select * from INFORMATION_SCHEMA.TABLES where upper(table_name) like '%DIM_MODEL%'

Best regards,

Tina

Referencing a variable set in an EXEC statement

I have code like this:
DECLARE @.CurrentValue nvarchar(1000)
EXEC('SELECT @.CurrentValue = min(Column) FROM Table')
PRINT @.CurrentValue
When I execute this code, I get an error message that I have to declare
@.CurrentValue. Apparently the code in the EXEC statement runs in it's own
scope and it doesn't see variables outside that scope.
But if I try to declare the variable inside the EXEC string, I can't access
it outside the EXEC statement.
I tried creating a global variable (@.@.CurrentValue), but that doesn't seem
to work either."MatthewR" <MatthewR@.discussions.microsoft.com> schrieb im Newsbeitrag
news:D5D08C86-E390-45C0-8D92-A341D457E50B@.microsoft.com...
>I have code like this:
> DECLARE @.CurrentValue nvarchar(1000)
> EXEC('SELECT @.CurrentValue = min(Column) FROM Table')
> PRINT @.CurrentValue
> When I execute this code, I get an error message that I have to declare
> @.CurrentValue. Apparently the code in the EXEC statement runs in it's own
> scope and it doesn't see variables outside that scope.
> But if I try to declare the variable inside the EXEC string, I can't
> access
> it outside the EXEC statement.
> I tried creating a global variable (@.@.CurrentValue), but that doesn't seem
> to work either.
>|||Hi,
try the following
DECLARE @.CurrentValue nvarchar(1000)
set @.CurrentValue = (Select min(Column) FROM Table)
Hope it helps
Regards
Alex|||Have a look here:
http://www.support.microsoft.com/?id=262499 Using OutPut Params &
sp_executeSql
Andrew J. Kelly SQL MVP
"MatthewR" <MatthewR@.discussions.microsoft.com> wrote in message
news:D5D08C86-E390-45C0-8D92-A341D457E50B@.microsoft.com...
>I have code like this:
> DECLARE @.CurrentValue nvarchar(1000)
> EXEC('SELECT @.CurrentValue = min(Column) FROM Table')
> PRINT @.CurrentValue
> When I execute this code, I get an error message that I have to declare
> @.CurrentValue. Apparently the code in the EXEC statement runs in it's own
> scope and it doesn't see variables outside that scope.
> But if I try to declare the variable inside the EXEC string, I can't
> access
> it outside the EXEC statement.
> I tried creating a global variable (@.@.CurrentValue), but that doesn't seem
> to work either.
>|||http://www.aspfaq.com/2492
This is my signature. It is a general reminder.
Please post DDL, sample data and desired results.
See http://www.aspfaq.com/5006 for info.
"MatthewR" <MatthewR@.discussions.microsoft.com> wrote in message
news:D5D08C86-E390-45C0-8D92-A341D457E50B@.microsoft.com...
>I have code like this:
> DECLARE @.CurrentValue nvarchar(1000)
> EXEC('SELECT @.CurrentValue = min(Column) FROM Table')
> PRINT @.CurrentValue
> When I execute this code, I get an error message that I have to declare
> @.CurrentValue. Apparently the code in the EXEC statement runs in it's own
> scope and it doesn't see variables outside that scope.
> But if I try to declare the variable inside the EXEC string, I can't
> access
> it outside the EXEC statement.
> I tried creating a global variable (@.@.CurrentValue), but that doesn't seem
> to work either.
>|||Look in the posting from ED and today (15.04.2005 20:47) (for Google
searcher the article
http://support.microsoft.com/defaul...kb;en-us;262499)
It describes using the Return value from an Execute. The problem is that in
the context of executing a new session is established and closed when the
statement was executed. So in the next line the value doesnt exists anymore
(in your query)
HTH, Jens Smeyer
http://www.sqlserver2005.de
--
"MatthewR" <MatthewR@.discussions.microsoft.com> schrieb im Newsbeitrag
news:D5D08C86-E390-45C0-8D92-A341D457E50B@.microsoft.com...
>I have code like this:
> DECLARE @.CurrentValue nvarchar(1000)
> EXEC('SELECT @.CurrentValue = min(Column) FROM Table')
> PRINT @.CurrentValue
> When I execute this code, I get an error message that I have to declare
> @.CurrentValue. Apparently the code in the EXEC statement runs in it's own
> scope and it doesn't see variables outside that scope.
> But if I try to declare the variable inside the EXEC string, I can't
> access
> it outside the EXEC statement.
> I tried creating a global variable (@.@.CurrentValue), but that doesn't seem
> to work either.
>|||> I tried creating a global variable (@.@.CurrentValue),
Where did you get the idea of a "global variable"? This is merely a
variable called @.CurrentValue, with a @. prefix to indicate it is a variable.
There is absolutely no difference between @.@.CurrentValue and @.CurrentValue.
A|||Thanks for the link. sp_executeSQL with OUTPUT parameters worked great!
"Andrew J. Kelly" wrote:

> Have a look here:
> http://www.support.microsoft.com/?id=262499 Using OutPut Params &
> sp_executeSql
>
> --
> Andrew J. Kelly SQL MVP
>
> "MatthewR" <MatthewR@.discussions.microsoft.com> wrote in message
> news:D5D08C86-E390-45C0-8D92-A341D457E50B@.microsoft.com...
>
>

Monday, March 12, 2012

Reference the reports DataSet from Code

Hi All,

From my reports code I would like to do some things with the reports DataSet. Is it possible to reference this object from within the report code?

Thanks,
Eric

http://msdn2.microsoft.com/en-us/library/ms157274.aspx

Reference Package Level Variables in a Script Component.

I am trying to reference a package level variable in a script component (in the Code) and am unable to do so successfully. I have it listed as a ReadOnlyVariables in the custom properties of the script component, however unable to reference it in the code.

Any help will be appreciated.

Thanks,

Andy.

Type "Me." and let intellisense help you from there.

-Jamie

|||

Jamie,

Thanks for your suggestion. I did that and I was able to locate the variable. What does "ME" refer to? Is it refering to the Script Component? Does typing ME in different procedures/functions within the Script Component refer to different things?

Thanks,

Andy.

|||

Now that I can reference the variable I am getting script component errors.

I am basically using the RowCount Component variable and reading into the script and writing it out to the destination.

I put the RowCount Variable in the ReadWriteVariables property of the Script Component since having it in the ReadOnlyVariables was hanging the application. But when I put it under the ReadWriteVariables, I get the following error.

The collection of variables locked for read and write access is not available outside of PostExecute.

at Microsoft.SqlServer.Dts.Pipeline.ScriptComponent.get_ReadWriteVariables()

at ScriptComponent_e27beb91ebac4849bc732f8d8577fd5c.Variables.get_CountID()

at ScriptComponent_e27beb91ebac4849bc732f8d8577fd5c.ScriptMain.WriteTrailerCount2()

at ScriptComponent_e27beb91ebac4849bc732f8d8577fd5c.ScriptMain.Input0_ProcessInput(Input0Buffer Buffer)

at ScriptComponent_e27beb91ebac4849bc732f8d8577fd5c.UserComponent.ProcessInput(Int32 InputID, PipelineBuffer Buffer)

at Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost.ProcessInput(Int32 inputID, PipelineBuffer buffer)

|||

OK, a couple of things:

1) Are your script and rowcount components in the same data-flow? This is not a good idea because the Rowcount component will not populate the variable until the data-flow is complete. If you want to use that value in the script component then you will have to break the data-flow into 2 and pass the data between the 2 using a raw file.

2) You can't reference variables listed in ReadWriteVariables inside the Input0_ProcessInputRow(Row) method. You can override the PostExecute() method which gets called when all the rows in the pipeline have passed through the component. ReadWriteVariables CAN be accessed in there.

What is it you're trying to achieve here?

-Jamie

|||

Jamie,

Firstly, I am very new to SSIS with no prior DTS experience, so please pardon my stupidity while asking questions.

1) Yes, RowCount and Script component are in the same dataflow. I wasn't aware that the RowCount variable gets populated once the data flow is completed.

2) By the time I reference my variable in the PostExecute() method isn't it too late since I need to write it out to the output buffer? I was able to programatically count the input rows and write it out. I was trying another way of accomplishing the same thing but instead of me programatically counting, I was wanting the RowCount Component to do that for me and me just grabbing the variable with the count in it and writing it out to the destination. Having the variable as ReadOnly on the script component basically hangs the entire dataflow and having it as ReadWrite causes an error when it reaches the script component.

3) Is there any documentation on the sequence of execution of methods in the script component?

|||

Andy_1979 wrote:

Jamie,

Firstly, I am very new to SSIS with no prior DTS experience, so please pardon my stupidity while asking questions.

No problem. We're all here to learn right? :)

Andy_1979 wrote:

1) Yes, RowCount and Script component are in the same dataflow. I wasn't aware that the RowCount variable gets populated once the data flow is completed.

Well this may not actually physically be the case but logically that is how you should think of it. There is certainly no guarantee that a variable populated in a component will be readable by another component in the same data-flow. You should never attempt to do this.

Don't think of the components as seperate "things". The lowest unit of execution is a data-flow. The components are just the constituent parts of that and it helps to think of them as of they are actually all executing at the same time

Andy_1979 wrote:

2) By the time I reference my variable in the PostExecute() method isn't it too late since I need to write it out to the output buffer?

Well it depends what you want to do. If you want to write it to the output buffer then you should be able to do this by splitting the data-flow into 2 as I previously suggested.

I'm actually more concerned about why you want to do this. I know I don't know your requirement but do you really need to put the same value into every single row in the pipeline? That strikes me as a strange thing to do.

Andy_1979 wrote:

I was able to programatically count the input rows and write it out. I was trying another way of accomplishing the same thing but instead of me programatically counting, I was wanting the RowCount Component to do that for me and me just grabbing the variable with the count in it and writing it out to the destination. Having the variable as ReadOnly on the script component basically hangs the entire dataflow and having it as ReadWrite causes an error when it reaches the script component.

The reason putting it in ReadOnlyVariables causes it to hang is because you are trying to read from it before the Rowcount component has finished with it. The Rowcount component has locked the variable. I refer you to my earlier point about how a data-flow executes. it is not as simple as just a series of sequential operations even though it looks as though it is.

Andy_1979 wrote:

3) Is there any documentation on the sequence of execution of methods in the script component?

Errr... probably yeah. Its fairly intuitive though. Perhaps this article in BOL will help: ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/dtsref9/html/2a0aae82-39cc-4423-b09a-72d2f61033bd.htm

Why do you want to put this value into the pipeline?

-Jamie

|||

Jamie,

Thank you so much for taking time to explain all of this. The RowCount Variable is written out to destination at the end of processing as a new row. It is not outputted on every single row. I basically want to count the number of input rows coming into my script component, process them and write them out but at the end write out an additional line which has the count of total rows processed.

Andy.

|||

Well it sounds as though the extra row you want to output will most likely have different column metadata to the rest of the pipeline and if that's the case then you won't be able to do this.

But...if you do want to...then here's what you should do.

Use a script component|||This whole variable story is a joke isn't it?|||

orbit wrote:

This whole variable story is a joke isn't it?

That's not a particularly useful statement. What do you mean? Do you have feedback for the product? If so, submit it at Microsoft Conenct.

-Jamie