473,421 Members | 1,531 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,421 software developers and data experts.

are stored proc local variables safe and unique for each call

I need a simple, efficient, safe sequence generator. Will this work? With no transaction?

Expand|Select|Wrap|Line Numbers
  1. ...
  2. Declare @foo as int
  3.  
  4. update seq set @foo=seq_val, seq_val=seq_val+1
  5.   where seq_name = 'yowza'
  6.  
  7. select @foo
  8. ...
  9.  
thanks
Aug 27 '10 #1
1 1011
ck9663
2,878 Expert 2GB
it depends on how you will use this sequence of numbers. This will return a table-like sequence of numbers. Since it's a Common Table Expression (CTE), you can use it to join to other table. Just make sure you don't over use this CTE, it's not a physical table and no index can be created for this one and could degrade the overall performance of your query.

Good Luck!!!

~~ CK
Aug 30 '10 #2

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

Similar topics

1
by: Cox News Server | last post by:
I'm a rookie with MSSQL. I need to run a DTS package to export a result set to an MX Excel spread sheet. I need to call the DTS from a stored procedure and pass it three values, depending on the...
1
by: Bill S. | last post by:
Hi, I a stored procedure that inserts a record into a table as below. The insert works OK, but if the insert violates a unique indewx constraint on one of the columns, the proc terminates...
9
by: Stefan Turalski \(stic\) | last post by:
Hi, I done sth like this: for(int i=0; i<10; i++) {...} and after this local declaration of i variable I try to inicialize int i=0;
10
by: Eric E | last post by:
Hi all, I am using an Access client linked to a PG 7.4 server via ODBC. I have a stored proc on the server that inserts rows into a table.particular table, accomplished via an INSERT within the...
5
by: John | last post by:
Hi all, I'm sorry I'm reposting this but the original was urgent and I do need closure on this. I'm calling a stored proc which does 4 "selects" and then I populate a dataset looping through...
6
by: Paul M | last post by:
Hi All, I'm currently writing a z/OS DB2 Stored Proc in C, using an example from the IBM Stored Procedure guide (SG24-7083-00). The database calls to read and update the database work...
4
by: Jay | last post by:
In VB.NET (Studio 2005) I need to loop thru a result set returned from a stored proc and generate XML for each row. E.g. exex procWhatever returns: custno, lname, fname, address 2, Doe, John,...
55
by: Zytan | last post by:
I see that static is more restricted in C# than in C++. It appears usable only on classes and methods, and data members, but cannot be created within a method itself. Surely this is possible in...
3
by: enreil | last post by:
Hello, I'm relatively new to the world of Stored Procedures in SQL Server. This may be a silly question, but I've done some searching and haven't come up with any solid answers. Is is possible...
0
by: DR | last post by:
I set my database to trustworthy and deployed this clr stored proc as unsafe ok but when i run this it returns 1 each time. as if ival keeps getting set back to 0 each time i call this clr stored...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.