I have taken three dtsx files and re written them into one each in its own container. I use the XML Task task alot which the File connection is set by a variable and the variable value is evaluated by expression (the expression makes up the path/filename from other variable values). All the variables that make up the connection are at the container scope. The package will not run now because it is saying that the source (created by variables) for the file connection do not exist.
It seems the answer is that file connections exist at the package level therefore the variable has to be at the package level. This seems to be alot of variables i now have to move to package level to generate the XML source connection. Which in essence makes it confusing as to which variables operate in which container.
My question is can we easily move variable scope (Not ideal as we have alot of variables at package level) Or Can we do the same for connection managers as we do for variables and have them only used in a scope? (this will be ideal as some connections only need to be at a container scope)
We have a problem with DATEFIRST. Different users connecting to SQL 2005 and querying the value for DATEFIRST (SELECT @@DATEFIRST). Some users get 7 (Sun), others get 1 (Mon). What is giving rise to the different values ? (All users seem to have the same language settings in SQL and their regional settings are the same). This is impacting stored procs calling DATEPART that are run from within VB6 Apps using ADO.
My week starts on Monday rather than on Sunday which is default(US, English) in SQL Server and would like to change the same so I would get proper weeknumber and dayindex using DATEPART.
I am looking at different ways of setting DATEFIRST(SET DATEFIRST 1) in SQL Server 2005.
I could set in a stored procedure, but this isn't a feasible way for me because I am using .nettiers to generate by business objects and stored procedures. I need to alter the sp's everytime I newly generate the code and sp's.
I couldn't set it in a function which I was hoping initially. I understand this datefirst is stored in one of the sys table in MASTER DB and I couldn't find a straight forward way to change this.
Can anyone suggest me a way to set the DATEFIRST either at a database level or at a server level(probably by changing the sys table in MASTER DB).
So I need to select and average a whole bunch of data by week. Currently, I group by:GROUP BY TO_CHAR(m.ENDTIME, 'IW') and select using SELECT ... TO_CHAR(m.ENDTIME, 'IW') Week to summarize by week. Since the first day of the year was a monday, it sets the weeks as monday-monday. 2008 will start the week on Tuesday. I need to set the weeks to be Thursday 7pm to Thursday 7pm. How can this be achieved? I'm not sure if datefirst is the answer. Can it accept decimals? Is there another way to do this? I'm placing this query into a SqlDataSource selectcommand. Unfortunately I do not have the option of building a stored procedure. Thanks.
I am setting my Dataset in SSRS to define the First Day of the week to Sunday. So In the Dataset I put this scripting : ================================== SET DATEFIRST 7; SELECT city, country, datepart(wk,transactdate) as WeekNo from CatalogTable ================================== The select statement above working very fine in the report.
But then, when I put in the Parameter which I have set in Report Parameter for a field called Service then I will get the problem. For example the scripting below : ================================== SET DATEFIRST 7; SELECT city, country, datepart(wk,transactdate) as WeekNo from CatalogTable where Service IN (@PService) ================================== I have defined @PService in Report Parameter, and in the Parameter Tab in Dataset inside SSRS. But it kept prompting me with the eror message : Error Source : .Net SqlClient Data Provider Error Message : Must declare the scalar variable "@PService".
When I remove the first line SET DATEFIRST 7; then my query working fine.
It seems SSRS cannot accept SET statement, whenever we insert the parameter in there. Is there any workaround on this ?
I have been using tis page as a reference http://forums.asp.net/thread/1511323.aspxbut i cant seem to get this to work. The above page suggests using Dim newId As Object = e.Command.Parameters("@RETURN_VALUE").Value to get the value but when i do that i get an error that Command is not a member of system.web.ui.webcontrols.formViewInsertedEventArgs Can anyone help?ThanksMatt
HelloI am trying to run a program to check for transaction scopeI have written the following code.But it seems I need to add a namespace or referenceWhat namespace am I supposed to addthanksusing (TransactionScope scope = new TransactionScope(TransactionScope.Required, options)){SqlConnection MyCon = new SqlConnection("server=hemalatha\sqlexpress;integrated security=sspi;database=demo");MyCon.Open();SqlCommand Mycmd=new SqlCommand("insert into t1 values 574,'scope','10/10/2007',3,3,3");Mycmd.ExecuteNonQuery();SqlConnection MyCon1 = new SqlConnection("server=hemalatha\sqlexpress;integrated security=sspi;database=persons");MyCon1.Open();SqlCommand Mycmd1 = new SqlCommand("insert into persons values 'scope',123,123,12,'scope'");Mycmd1.ExecuteNonQuery();}
Hi folks I'm using a function to create a record on a database, and then I want to return the ID of that record to passinto another function. I believe its scope identity that does this, but I'm not sure how to do it. public static void putrecordin(string record) { SqlCommand cmd = new SqlCommand("insert Table (record) values (@record; scope identity)" conn.Open(); cmd.Parameters.Add(new SqlParameter("@record", record)); cmd.ExecuteNonQuery(); conn.Close(); another(new-record-ID, anothervalue); } public static void another(string new-record-ID) {do stuff } so you'll see I have a function called putrecordin, and at the end of the sql statment I want to return the id of the new record and pass it into another function called another. Anyone know how to do this? Thanks!
In the following Query, is Table1.Column3 updated in the subquery for each row in Table1, or does it take the first value, or is it NULL, or is it ____?
Select Column1, Column2 from Table1 where Column1 IN (Select Col1 from Table2 where Col2 > Table1.Column3 Group by Col1 Having count(Col1) > 1) and Table1.Column3 < Column4
To Parse it out. This then has to be inserted into another table with an identity column (damn Identity column), and I need to grab the generated id for each row, because then there are other children tables that need to be populated.
Question: Is there any set way to grab multiple generated id's? Or do I need to loop or use a cursor?
Is an index in a database the equivalent for a <TH scope="col"> in a columnof atable in the html code?--Luigi ( un italiano che vive in Svezia)https://www.scaiecat-spa-gigi.com/s...kor-italien.php
I've been trying to figure out the usage of "Nothing" as the scope parameter, and the more I try, the more I can confused.
It says on the RDL spec:
"For expressions inside data regions:
.......
Specifying the keyword Nothing as the scope is equivalent to specifying the outermost data region containing the report item in which the aggregate is used."
It seems that what's it saying is that if I have an expression in a table as = last(somefield, "the name of the table") is the same as = last(somefield,Nothing) But, apparently it;s not. (I tried last, first,sum, count,CountRows, min, max...........) it doesn't matter where I put "=last(somefield,Nothing)" in the table (i tried table header,footer, detail, and table group header, footer), none of them worked. and I tried it everywhere in matrix, in charts. It's just not working. It always complains about the invalid scope not being the containing data region, containing grouping or dataset name.
However, the only way I get the "Nothing" as the scope to work is in a RunningValue function, not in any other aggregate funcitons.
Anyone help me with this, please... I need a complete definition on the usage of Nothing as scope.
Variable scope of package variables should be in a dropdown. I want to copy (20+) variables from one sequence container to another. Do I have to retype all the names, types and initial values because I made the mistake not to place them one level higher?
I am really starting to like CTEs. My only qualm is that you can only use them within the first statement after you declare them. I wish they would remain active for the duration of the sql batch just like everything else (variables,local temp tables, ect). Is there any trick so that you can use them multiple times? Maybe define them as a string and do dynamic sql or something like that? Hopefully (i have not researched the new version of sql server) in SQL Server 2008 the scope has increase. Anyways any help would be appreciated.
Hi, I've been trying to insert data in a Sql server (.mdf) db and use SCOPE IDENTITY to be able to insert an id in both the parent and the child tables. However, I don't know how to write one of the lines correctly: Dim MyConn As SqlConnection = New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("myConnectionString").ConnectionString) Dim MySQL As String = "INSERT INTO Document (fid, serie, vnr, datum, vtext, sign) " & _ "Values (@fid, @serie, @vnr, @datum, @vtext, @sign) Select @verid=SCOPE_IDENTITY()" Dim Cmd As New SqlCommand(MySQL, MyConn) With Cmd.Parameters .Add(New SqlParameter("@fid", fid)) .Add(New SqlParameter("@serie", SerieDropDownList.SelectedValue)) .Add(New SqlParameter("@vnr", vnr)) .Add(New SqlParameter("@datum", datumet)) .Add(New SqlParameter("@vtext", VtextTextBox.Text)) .Add(New SqlParameter("@sign", sign)) .Add(New SqlParameter("@verid", SqlDbType.Int)) 'HERE IS THE LINE THAT SHOULD BE CHANGED (OR SO I THINK) End With MyConn.Open() Cmd.ExecuteNonQuery() Dim p As SqlParameter = Cmd.Parameters.Add("@verid", SqlDbType.Int) p.Direction = ParameterDirection.Output Dim verid = Cmd.Parameters("@verid").Value.ToString For Each row As GridViewRow In StampelGridView.Rows Dim kpnr As String = row.Cells(0).Text Dim kst As String = row.Cells(1).Text If kst = " " Then kst = "" Dim projekt As String = row.Cells(2).Text If projekt = " " Then projekt = "" Dim debettext As String = "0.00" Dim kredittext As String = "0.00" If row.Cells(3).Text.Length > 3 Then debettext = Replace(row.Cells(3).Text, ",", ".") If row.Cells(4).Text.Length > 3 Then kredittext = Replace(row.Cells(4).Text, ",", ".") Dim ptext As String = row.Cells(5).Text If ptext = " " Then ptext = "" Dim MySQLpost As String = "INSERT INTO Vpost (verid, kpnr, kst, projekt, debet, kredit, ptext) " & _ "Values (@verid, @kpnr, @kst, @projekt, @debet, @kredit, @ptext)" Dim Cmdpost As New SqlCommand(MySQLpost, MyConn) With Cmdpost.Parameters .Add(New SqlParameter("@verid", p)) 'THIS SHOULD CHECK OUT AS WELL... .Add(New SqlParameter("@kpnr", kpnr)) .Add(New SqlParameter("@kst", kst)) .Add(New SqlParameter("@projekt", projekt)) .Add(New SqlParameter("@debet", debettext)) .Add(New SqlParameter("@kredit", kredittext)) .Add(New SqlParameter("@ptext", ptext)) End With Cmdpost.ExecuteNonQuery() Next MyConn.Close() In other words, the verid is the id of the new post in the first table. This id should be inserted in the new table as well. Thank you very much in advance fro helping me out! I've worked a LONG time with this. Pettrer
Is it possible to write the InsertCommand for a SqlDataSource to return the value of the AUTONumber of a field generated when a new record is added to a database table and display that value on label1.Text after the postback of ItemInsersted event? For example, <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NearMissConnectionString >" InsertCommand="INSERT INTO [NearMiss] ([Branch], [Division] VALUES (@Branch, @Division); SELECT SCOPE_IDENTITY()" SelectCommand="SELECT [NearMissID], [Branch], [Division], FROM [NearMiss]" <InsertParameters> <asp parameter Name="Branch" Type="Int32" /> <asp parameter Name="Division" Type="String" /> </InsertParameters> </asp:SqlDataSource>
NearMissID would be the value of the autonumber generated by the SQL Server
I am trying to retrieve the value of the autonumber generated when a new record is inserted into a SQL 2000 Database using a SqlDataSource attached to a FormView. Is this possible? Can some give me a short example of how to retrieve that value and display it in a textbox? Thanks for any help with this. It seems like it would be a common issue for .net developers.
Hi, I have been trying to get the scope Identity after inserting a record using an ObjectDataSource. I can't find what event, or how to get the value that the scope identity returns. Here is my Sproc.
ALTER PROCEDURE dbo.[YourCompany_LanCustomer_Insert] ( @DNNUserID int, @FirstName nvarchar(50), @LastName nvarchar(50), @Address nvarchar(50), @Address2 nvarchar(50), @City nvarchar(50), @State nvarchar(50), @Zip nvarchar(50), @EmailAddress nvarchar(50), @PhoneNumber nvarchar(50), @CustomerID int OUTPUT ) AS INSERT INTO YourCompany_LanCustomer (DNNUserID, FirstName, LastName, Address, Address2, City, State, Zip, EmailAddress, PhoneNumber, DateEntered) VALUES (@DNNUserID, @FirstName, @LastName, @Address, @Address2, @City, @State, @Zip, @EmailAddress, @PhoneNumber, getdate()) SET @CustomerID = Scope_Identity() RETURN
This is kind of what I'm trying to do in my MS SQL 2000 query. ShouldI be able to reference s1.col1 inside the 2nd derived table?I'm getting 'Invalid column name col1' and it's coming from the 2ndderived table (I've commented out other refs to just it to check).Maybe I need to use a temp table instead.SELECT s1.col1,(SELECT * FROM(SELECT COUNT(zzz) AS SomeTotalFROM tab1WHERE s1.col1 = zzz)) AS RowCount) /* error here */FROM(SELECT col1 FROM table) AS s1Thank you!
We're working on a new release of a software.In the existing version, each client connects and executes a long batch ofanalysis on some tables.In the new release, we need to allow each client to execute analysis on asubset of data, according to certain login information.Our idea is:1) Connection to db2) Creation of one View according to restrictions3) Execution of analysis using just created view and some tables.The problem is that executingcreate view myvista asselect * from tb_data where testo='A1'from two different clients, creates just one view.Question: Does it exist a way of creating a VIEW with a connection scope,something like 'select into ##temptable'?We tried Create View #MyVista or ##Myvista, but this name is not accepted.Alternative way, is creating a ##TempTable, at the beginning of the batch,and using it as data source instead of full table, but, due to really hugeamount of data, this could really disturb server performances.Thanks for any helpAlberto
I have a detailed report ..with summary lines and detailed lines (drill down).
I have a column with a function "RowNumber(Nothing)" which is supposed to just count the rows
when I put this in the summary row for the column I need in the Design Layout section and run the report, I get numbers on the summary lines which include the number of rows in the level below (detailed rows).
I just want to number the summary rows sequentially without taking into consideration, the number of detailed rows.
How do I modify RowNumber(Nothing) to exclude counting the detailed rows....???
I have 2 packages and they get executed in SQL Job.
Each of these package will have seperate transactions with the Database and I am not sure of how to maintain the transactions between these 2 packages.
Can someone explain me the necessary setting to achieve this. If I set the TransactionOption property to Required (or) Supported in both these packages, will the Transaction Scope of the first package extend to the second one.
For me, If the second package ends up in error, the first package should also have to be rollbacked.
Source table : Result (contains 100 rows with primary key Reuslt_ID)
Destination Table : stage_RESULT (same structure as source table)
Source table gets regular inserts with new result_ids. I want my package to pick up new result_ids only, i.e. (Result_ids > maximum(result_id) in stage_RESULT.
My package is designed to do the following :
1) Retrieve current maximum result_id into @max_result_id from RESULT_STAGE
2) Retrieve rows from Result where result_id > @max_result_id
sounds simple, BUT.. it's not working.... my source table resides in a SQL Server 6.5 database so I am having to use a datareader source adapter to pull the data.
The first time I run the package (when my stage_RESULT) is empty, the package pulls all 100 rows from the source to the destination table, but the second time I run it, it still retrieves all 100 rows again even though the value of the variable is greater than all result_ids in the source.
What am I doing wrong?
I have a variable defined at the package level. I use a SQL Query Task to assign a value to this variable (this bit works just fine). I then use this variable in my data flow task in order to retrieve data using the My expression used for my datareader source adapter is :
"select * from result where result_id > " + (dt_str, 10, 1252) @[max_result_id]
Hi, i'm trying to run wrap a transaction around a block of code to make sure every statement is carried out. Here's what i have: using (TransactionScope ts = new TransactionScope()) { ... ts.Complete();}The code executed in the ... part is a set of sql commands within my dal. If this above expression takes less than 30 seconds everything is carried out correctly, however if it takes longer than 30 seconds i receive an sql timeout error. I tried modify the above code to: using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, TimeSpan.FromMinutes(5))) { ... ts.Complete();} But it did not seem to make a difference. I suppose the easiest option would be to increase the timeout for every sql command in my dal but i feel that the 30 second timeout is sufficient for a single command. Appreciate if someone could tell me how this should be done correctly. Thanks
My office gave me assignment to find out the scope & limitations of the two Microsoft database applications - MS Access and MS SQL Server. After the findings, we have to chose the more appropriate database for our new project, which will have a humble start but may grow big in a year or two.
I will apreciate the info in facts & figures (not only in general).