loop though table using RowID, not cursor (was "Loop")

I have a table with RowID(identity). I need to loop though the table using RowID(not using a cursor). Please help me.

Posted On: Friday 26th of October 2012 12:02:08 AM Total Views:  292
View Complete with Replies

Related Messages:

Issues importing a text file (tab delimited) to a SQL table   (332 Views)
I have a text file I am trying to import to a table. This text file is in a tab delimited format. I am using DTS to import the data to a new table I made. The fields are varchar and are set to allow nulls & allow 8,000 characters per field. The error I am getting is that the data exceeds the allowed amount (or something like that) in col4. Now I have checked everything in column 4 and nothing exceeds 5,000 spaces/characters combined. I have checked the entire sheet (in excel) for that fact, and there is not one single column/row/cell that exceeds 5,000 spaces/characters combined. What the heck could be causing SQL to tell me I am trying to import too much data in one column when there is nothing that even comes close to 8,000 characters & spaces combined
Code for creating a table in SQL from external source   (340 Views)
I'm looking to create a table in SQL using data from the as/400. I need some code that extracts it from as/400 using odbc and I need it to loop and create that table every minute. The file its retrieving is a live file but not very large.. I need to basically poll the data. Does anyone have code for something like this..
add checkbox column to access table (was "SQL query help.., please, any one??")   (290 Views)
good people of this forum.. I am working on an eccess db, and using asp to update, change and so on... I want to add dynamicly a field to the db, using the ALTER TABLE command, but for some reson I can't find a way to make it work, the field type I am trying to add is boolean, and I want it to show up in the actual db as a checkbox, and not as a bit field (0/1), so I've been trying this and non of them work, and I couldn't find any sites with examples for this... any help would be very appricated..., this is what I've tryed so far and didn't work: "ALTER TABLE [Users] ADD [CHILD] boolean" "ALTER TABLE [Users] ADD [CHILD] boolean False" "ALTER TABLE [Users] ADD [CHILD] boolean(f)" "ALTER TABLE [Users] ADD [CHILD] boolean f" me out on this
table Self-joins with updates   (327 Views)
table = PEOPLE Name Money Type ----- ----- ---- Steve 400 R Steve 100 R Paul 500 R Paul 100 R Matt 500 R Matt 200 R Matt 0 T Steve 0 T Paul 0 T I'm trying to add-up all of the Money values for each Name and store them into their names, but under Type 'T'. after the update command it should look like this Name Money Type ----- ----- ---- Steve 400 R Steve 100 R Paul 500 R Paul 100 R Matt 500 R Matt 200 R Matt 700 T Steve 500 T Paul 600 T
Trying to pull data from 2 tables into a query   (302 Views)
I'm trying to create a SQL query to pull together a job info table and a customer info table in an Access DB. We can't have a unique ID on the customer that we can store in the job table because the customer info is dumped from Exchange and the ID (row number) in the cust_List table will change each time we export from Exchange. What I need to do is go through jobs, get the CO_ID, the CONTACT_LN and the CONTACT_FN and then match it against Customer_List>Account, Lastname, Firstname. Any ideas
Checking duplicate values two tables   (337 Views)
Hi , Is it possible in SQL to Restrict value in one table checking a value on anather tables. Scenerio-1. I have two table let say, Teb1 and Teb2. Teb1 has a column called- Business_type and Teb2 has a coulmn called Incorporated_date. I just need to restrict If the value of Business_type column in Teb1 is "Propritory" then Incorporated_date in Teb2 should not be blank (nulll) . Otherwise it can take null value. Scenerio -2.[/B] I have table called [B]SIC. This table has a two column called SIC1 anc SIC2 . Is it possible to restrict that clumn SIC1 and SIC2 should have same values( duplicate values cannot be entered in both columns. Please Advise. Vijay
Converting a SQL table into Text file   (337 Views)
How to convert a SQL table into Text file I have a table and I want to extract the values with the field names above to a text file. The query should also allow me to define the starting position of the fields in the text file. email:
Copying data from one table to another table   (290 Views)
I need to copy data from one table into another table. The field names are NOT the same: I need to INSERT Table 1 fields: cdescurl cname cdescription cimageurl category cprice INTO Table 2: product_url name description image_url category price How do I do this Thank you in advance for any help you can give me!
copy table to different server   (334 Views)
i need a script that can copy a table from a db on one server to another for me, but i have no idea how.. help much appreciated !
aggregates from two unrelated tables   (367 Views)
Hi I have similar problem and i explained in detail here Pls help me to fix this sql Regds Bala
Combining info from two tables?   (398 Views)
, I'm having some problems trying to access two tables in a SQL database at the same time and making some results out of them. Let me explain further: the first table has some information in that I'm going to be doing a select query on and reading out, but one of the columns in this table is a set of codes, the second table contains the codes in one column and their meanings in the other. So I want to bring back the information from the first table and then select the information for the codes shown from the second table and print their meanings alongside the information from the first table. Could anyone help me out in figuring out how my SQL in the ASP page for this would be written Sorry if this is a little confusing but im having a hard time visualising how to do this.
Help with MS SQL Server - updating data from 2 tables   (327 Views)
Hi all, Please forgive me, but I'm new to MS SQL Server and I have few questions. First of all I'd like to know if there is a way to update one table with the data from another. Let's say I have 2 tables. TableA table contains the voucher numbers; TableB table contains the image numbers. Is there a way to merge Voucher numbers from TableA table to Image numbers in TableB table if we assume that there is a primary key Voucher Number in both tables If yes- what would be the query structure for that Please forgive me if you think that this question is silly, I have to say I'm not just new to SQL I'm VERY new to it Thank you in advance.
problem w/ linked table permissions   (319 Views)
This question involves SQL server as well as Access, so I hope that someone can follow. I'm trying to give someone read and write access to a table in SQL server through a linked table scenario in Access. I set up a new user account with datareader and datawriter permissions and made sure it went into the particular table as well. I also re-created the DSN on the user's local machine using this new login information. However, each time you open up the table after logging in using this info and try to edit a field, it gives a "Write Conflict" error and gives three choices: Save Changes, Copy to Clipboard, Drop Changes and of course, Save Changes is disabled. We also tried logging in using the db admin account and it won't work. Anyone have similar experiences with this If so, is there a work-around so that you can edit data through Access
How to cursor loop   (100 Views)
Dear ALL i'm declared a cursor that cursor inside one loop, every time i want to fetch first record pls help me advance
Stored procedure with nested while loop   (155 Views)
Alright folks I'm looking to get a set of results from a stored procedure that displays amounts of money deposited in each particular month. Here is an idea of what I'm looking for - I hard coded the dates to get this result: What I would like to do is use a while loop to increment the date by one month and gather the money deposited as another column, but I'm struggling to get it to work. Not sure if it can! Code: Declare @startDate datetime Declare @EndDate datetime Set @startDate = convert(datetime,'01/04/2008' ,103) Set @EndDate = convert(datetime,'01/05/2008' ,103) Begin Select FundTypeName, While (@EndDate < convert(datetime,'01/05/2011' ,103)) Begin (SELECT Amount FROM Summary WHERE DepositDate >= @startDate AND DepositDate < @EndDate) Set @startDate = dateadd(m,1,@startDate) Set @EndDate = dateadd(m,1,@EndDate) End FROM Summary INNER JOIN FundTypes on Summary.FundTypeID = FundTypes.FundTypeID WHERE Summary.FundTypeID = 1 and ProjectID = 1 End As you can see, I'm trying to nest a while loop inside a Select statement in order to extract new columns. I'm fairly new with stored procedures so not sure where I'm going wrong, but I'm getting errors on the BEGIN and END lines. Is it not possible to nest BEGIN and END's I'm sure it would be better in a different format but sadly our client wants it this way... Hopefully someone knows where I'm going wrong!
looping paypal cart to accessDB in asp file   (202 Views)
I would be eternally greatful to anyone to debug the following mess, Thank you Very much! James Kulesza The concept came from thebomb
Weird bug: insert not working in while loop in my stored procedure. Please help!   (126 Views)
I am building up a product catalog. I use one table Category(id, name, parentId, isExpanded) to store all the categories in a tree structure. "id" is an identity column that has its value auto-incremented. "parentId" is a foreign key that references the "id" column of the same table. A category copy function is required, which should be able to copy a specific tree branch and put it under another tree node. After the branch is copied, all the nodes involved should be returned to another component with their old "id"s and new "id"s. I need to use a stored procedure to implement this copy function. But I was disappointingly stuck with the "insert" statement not working within the second "while" loop (as shown in the following code). No error was returned, there is just nothing inserted in the table at all. The first parameter of the procedure is the id of the top-most node of the branch to copy and the second parameter is the id of the destination node to which the copied branch will be appended. Please help me check out the code. And if possibly, please run this procedure on your server and see whether it will work. Thank a lot. Code: ALTER PROCEDURE Category_Copy @id int, @parentId int AS DECLARE @children TABLE (rowId BIGINT IDENTITY(1,1), [id] int, [parentId] int default null, [level] int, [newId] int default null, [name] varchar(100) default null ) DECLARE @level int BEGIN INSERT INTO @children ([id], [parentId], [level], [newId], [name]) SELECT @id, [parentId], -1, null, [name] from Category WHERE id = @id SET @level = 0 INSERT INTO @children ([id], [parentId], [level], [newId], [name]) SELECT [id], [parentId], @level, null, [name] from Category WHERE parentID = @id WHILE @@ROWCOUNT > 0 BEGIN SET @level = @level + 1 INSERT INTO @children ([id], [parentId], [level], [newId], [name]) SELECT c.[id], c.[parentId], @level, null, c.[name] FROM Category c JOIN @children i ON c.[parentId] = i.[id] AND i.[level] = @level -1 END -- Prepare additional variables for looping through the table variable DECLARE @varMaxCount BIGINT DECLARE @varCurrentCount BIGINT SELECT @varMaxCount = max([rowId]) FROM @children -- End Prepare -- Loop through the table variable DECLARE @intLoops INT SET @intLoops = 0 -- Debuging line WHILE @varCurrentCount
Stored Procedure - Catch variable data in a while loop..   (120 Views)
I'm not quite sure how to make this work. The SQL syntax worked fine if I comment out this line of code but it wouldn't work if I un-commented it out. Take a look at the "@TblPurchaseRaw_RawID" variable... Code: DECLARE @TblPurchaseRaw_RawID INT DECLARE @TblPurchaseRaw_AccountID INT SELECT RawID INTO #tmpTblPurchaseRaw FROM tblPurchaseRaw WHERE AcceptedID = 0 WHILE EXISTS (SELECT TOP 1 RawID FROM #tmpTblPurchaseRaw) BEGIN --SET @TblPurchaseRaw_RawID = RawID SELECT TOP 1 @TblPurchaseRaw_AccountID = AccountID, @TblPurchaseRaw_AcceptedID = AcceptedID FROM tblPurchaseRaw WHERE RawID = @TblPurchaseRaw_RawID DELETE FROM #tmpTblPurchaseRaw WHERE RawID = @TblPurchaseRaw_RawID END
trigger infinite loop   (136 Views)
The following trigger gives me an "nesting limit exceded error" (in other words an infinate loop) the trigger is recursive but the recod i tested it out on had only 3 child rows, since no other triggers are active on that field, there is no way it could have gotton up to 32 al on it's own , or am i wrong any help would be appriciated PHP Code: CREATETRIGGERdbo.Optionaliteit_CascadeONdbo.Offerte_LijnenAFTERUPDATEASIFUPDATE(Optioneel)BEGINUPDATEOfferte_LijnenSETOptioneel=(SELECTinserted.OptioneelFROMinserted)WHEREParent_IDIN(SELECTinserted.Lijn_IDFROMinserted)END
Recordset loops and javascript......   (107 Views)
Im trying to perform a Javascript function for each iteration of a retrieved recordset. However as expected, I found the two don't always like working in tandom together. Basically my function needs data from the record set, does some calculations and then the recordset needs to be updated. I am finding that only the last record in the RS is being processed and would be very grateful if anyone could provide some suggestions as to how I may get around this