What you need to do is create a cursor (loop), and another cursor inside of it.
Your outer cursor will grab each record. Place the values in variables. Then on the inner cursor, you need a variable (integer) that is incremented each pass. Inside of this inner cursor you will have the actual...
It's by no means fool proof, and you could argue it's hardly random. However, if there is a character field longer than 60 characters in your table, you could do something like this.
select top 1 *
from your_table
order by substring(field1,datepart(s,getdate()),10)
This orders the table...
although I'm not familiar with Oracle. It sounds like you want to use CAST. syntax would be something like:
CAST(your_field as CHAR(100))
of course, you would pick whatever datatype and length fits your needs.
Assuming you're using MS SQL Server....there is a function in transact SQL called "pivot table" that works for this type of situation. It busts out the values of a field into columns, and aggregates the data. I'm not sure of the syntax, however. Read up on it in Books Online.
as rac2 stated, more info would be helpful.
Sounds like you could use a trigger to accomplish your goal. Although, I'm operating under the assumption you're using MS SQL Server.
First, you need an auto-incrementing field. In this case I'll call it ID. And since you didn't supply a table...
Here's how I would write it.
Update component
set ComponentTag = ('010' + substring(ComponentTag,4,4))
where substring(ComponentTag,1,3) = '001'
--this is assuming your ComponentTag field is only 7 characters long.
Hope this helps...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.