473,396 Members | 1,966 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Stucking Stored Procedure for records >300

228 100+
0
down vote
favorite


I am having a bit of a problem in SS 2008. I have a front-end form that sends item type and quantity. Then SS would produce IDS that equal the number of the given quantity for the given items. So the input is like:

Laptop 1000 UPS 10

The above wouldnt work cos laptops are 1000. But the following works:

laptop 300 ups 350 desktop 300 calculator 300 ... the sum can go beyound 1000 totally as long as the individual items are below 350

Portion of the Code I have is:
Expand|Select|Wrap|Line Numbers
  1.  
  2. DECLARE @ids varchar(max)=''
  3. DECLARE @currentid varchar(15)
  4. DECLARE @begin int=0
  5. DECLARE @intgenwhat smallint -- GENERATE A NUMBER OR A LETTER?
  6. DECLARE @currentidlength smallint
  7.  
  8. DECLARE @ownercode varchar(3)='ABC'
  9.  
  10. BEGIN
  11. SET
  12. while @begin<@p1
  13. BEGIN
  14. SET @currentid=''
  15. set @currentidlength=LEN(@currentid + @callercode)
  16.       while @currentidlength<15
  17.         BEGIN
  18.         SET @intgenwhat=FLOOR(2 * rand())
  19.              if @intgenwhat=0
  20.               SET @currentid= @currentid + cast(char(FLOOR(10 * rand()) + 48 ) as varchar)
  21.               else
  22.                 SET @currentid= @currentid + cast(char(FLOOR(10 * rand()) + 65) as varchar)
  23.  
  24.         SET @currentidlength=@currentidlength + 1
  25.  
  26.         END 
  27.         SET @ids=@ids + @ownercode + @callercode +  @currentid + ','
  28.  
  29.  
  30.  
  31.  
  32.  
  33.         SET @begin=@begin + 1
  34. END 
  35.  
  36. --remove last ,
  37. SET @ids=dbo.DSSMSFN_strRemoveCharacters(@ids,1,len(@ids)-1)
  38.  
  39. END
  40. SELECT @companyids= @ids
  41.  
It works as expected. It returns the needed IDs in CSV. But if quantity of a single type is more than 350, it stucks and returns nothing. The sum of single types can be greater than 1000 even and its result is as expected.

Is it a timeout issue? I cant understand whats happening at all since the total quantity can be higher and it works but fails if a single
Jul 10 '15 #1
6 1567
computerfox
276 100+
I don't quite understand the issue.
This is normal and that's why sites with a large amount of content tend to have multiple pages or a page with a start and end index. What you can do is go to your SQL Server manager and see how long it took for it to run the same query. By the way, if you're dealing with a large amount of content and have a front-end, I would actually consider MySQL since it's built just for that.
Jul 11 '15 #2
samvb
228 100+
thanks...poor english. it is not to display records...it is to insert records. I neeed to generate ID numbers for say 500 computers and insert each into table.
Jul 12 '15 #3
Rabbit
12,516 Expert Mod 8TB
What you say you're doing and the code you posted don't match up. There's nothing in there that inserts a record. You have variables that aren't declared. And you call user defined functions that we have no idea what they do. With all this missing information, it's hard to diagnose your issue.
Jul 12 '15 #4
samvb
228 100+
I posted the SP that is called by the inserting SP. The above SP just generates CSV id numbers which are processed by the calling SP that inserts the records into the table (not shown here). Anyway...it is now solved.
Jul 12 '15 #5
samvb
228 100+
btw, how do i close a topic?
Jul 12 '15 #6
Rabbit
12,516 Expert Mod 8TB
There's no need to. But can you post your solution in case someone runs into the same problem you had?
Jul 13 '15 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: deprins | last post by:
Hello, I have wrote a stored procedure but its real slow. Its activated by a button on web page but its takes to long to process and the web server gives a timeout message after 5 minutes. Is...
1
by: Brad H McCollum | last post by:
I've designed a very basic SQL Server Stored Procedure that I'm using via a Visual Basic 6.0 front-end file in retrieving records into a data entry form. I can't for the life of me get the...
1
by: Dan Caron | last post by:
I have to create a stored procedure to purge "x" # of records from a table. I have two tables (script below): Schedule ScheduleHistory I need to purge records out of ScheduleHistory. The...
0
by: Nashat Wanly | last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET View products that this article applies to. This article was previously published under Q310070 For a Microsoft...
5
by: Timppa | last post by:
Hi, Could anyone help me with my problem ? Environment: Access 2000 and Sql Server 2000. I have a stored procedure as follows: DROP table1 SELECT alias1.field1,alias2.field2,table2.field6...
6
by: Wojciech Wendrychowicz | last post by:
Hello to All, I'm trying to retrieve records from AS/400 in an VBA application. So, I've made an RPG program, then a stored procedure wchich calls that RPG program, and finally some VBA code to...
0
by: franjorge | last post by:
Hi, I have created two stored procedures via VB using this code: sql = "CREATE PROC " & nombre_proc & " AS SELECT *" & _ " From MBM_PUNTOS_SCE_SIN_COINCIDIR_SIEGE_FALTA_PM_NE_" & mes & _ "...
9
by: vikram.mankar | last post by:
I have a stored procedure thats transferring/processing data from one table to two different tables. The destination tables have a unique value constraint as the source tables at times has...
0
by: gregoryday | last post by:
I am having a problem with creating a stored procedure. The premise underwhich we are operating is the following: We are working with two tables. The first table simply stores an integer value...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.