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

Updating data in a table

Expand|Select|Wrap|Line Numbers
  1. SET QUOTED_IDENTIFIER OFF 
  2. GO
  3. SET ANSI_NULLS ON 
  4. GO
  5.  
  6.  
  7.  
  8. ALTER   Function dbo.ZeroFill_ObjectNumber (@ObjectID int,@ObjectNumber char(42), @SortNumber char(56),@ComponentNumber varchar(42))  
  9. RETURNS Varchar(2000) AS
  10.  
  11. BEGIN
  12.  
  13. declare @stringvar as varchar(255)
  14.  
  15. declare cur CURSOR FOR select  Objects.ObjectId,  Objects.ObjectNumber, Objects.SortNumber, objComponents.ComponentNumber
  16.      from Objects, ObjComponents
  17.     where ObjectLevelID = '6'
  18.     and objectnumber like 'GR%'  
  19.     and  objectnumber not like 'GR[0-9][0-9][0-9][0-9]'
  20.     and objectnumber not like 'GR[0-9][0-9][0-9][0-9][.][0-9][0-9][0-9][0-9]%'
  21.     and objectnumber not like 'GR[0-9]'
  22.     and Objects.ObjectId = ObjComponents.ObjectId
  23.  
  24. OPEN cur
  25.     set @stringvar = '' 
  26.  
  27. fetch next from cur into @stringvar
  28. While @@fetch_status = 0
  29. BEGIN
  30. IF @stringvar Like '%.[0-9][0-9]/%'
  31. Begin
  32.     set  @stringvar =  substring(@stringvar,1,patindex('%.%',@stringvar)) + '00' +substring(@stringvar,patindex('%.%',@stringvar)+1 ,len(@stringvar))
  33.  
  34. End
  35. Else If @stringvar Like '%.[0-9][0-9][0-9]/%'
  36. Begin
  37.     set  @stringvar =  substring(@stringvar,1,patindex('%.%',@stringvar)) + '0' +substring(@stringvar,patindex('%.%',@stringvar)+1 ,len(@stringvar))
  38.  
  39. End
  40.  
  41. fetch next from cur into @Stringvar
  42.  
  43. END
  44. CLOSE cur
  45. DeAllocate cur
  46.  
  47. return @stringvar
  48.  
  49. END
  50.  
  51.  
  52. GO
  53. SET QUOTED_IDENTIFIER OFF 
  54. GO
  55. SET ANSI_NULLS ON 
I need to update the objectnumber once I have zero filled. I think this is a good function could use some help finishing.
Aug 24 '07 #1
2 1133
pbmods
5,821 Expert 4TB
Mickpiper, please use CODE tags when posting source code. See the REPLY GUIDELINES on the right side of the page next time you post.
Aug 24 '07 #2
code green
1,726 Expert 1GB
Are you asking how to create an UPDATE query?
Aug 28 '07 #3

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

Similar topics

11
by: Jason | last post by:
Let's say I have an html form with 20 or 30 fields in it. The form submits the fields via POST to a php page which updates a table in a database with the $_POST vars. Which makes more sense? ...
1
by: Srinadh | last post by:
Hi all, We have files with about 20 to 30 fields per row. We are trying to update such files with about 60 rows as contiguous data in a CLOB field. It passes through. But when we try...
1
by: Mark | last post by:
I'm having a problem updating recordsin an Access DB table. I can update other tables in this db with no problem, and I can dreate new record in all of the tables (including this one.)> But I can't...
5
by: junglist | last post by:
Hi guys, I've been trying to implement an editable datagrid and i have been succesful up to the point where i can update my datagrid row by row. However what used to happen was that once i updated...
10
by: jaYPee | last post by:
does anyone experienced slowness when updating a dataset using AcceptChanges? when calling this code it takes many seconds to update the database SqlDataAdapter1.Update(DsStudentCourse1)...
4
by: Geoff | last post by:
Hi I'm hoping somebody can help me with the following problem that has occurred to me. Suppose I have two tables in an SQL Server database. Let's call these tables A and B. Assume that A has...
4
by: rdemyan via AccessMonster.com | last post by:
My application is calculation intensive and the servers are agonizingly slow. Administrators of my application only update the backends once a month (twice a month max). So, my launching program...
33
by: bill | last post by:
In an application I am writing the user can define a series of steps to be followed. I save them in a sql database using the field "order" (a smallint) as the primary key. (there are in the range...
3
by: Trez | last post by:
Hey guys, Am new at using ASP.Net. am having some problems updating my SQL DB. whenever i try i get this Error. Can someone help me? Incorrect syntax near 'nvarchar'. Description: An unhandled...
2
by: =?Utf-8?B?VmFuZXNzYQ==?= | last post by:
Hi All! I am with a situation where I am not getting the right updating to the form's fields. The situation is the following one: I have one combobox and one textbox. I am using the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
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
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...

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.