473,753 Members | 6,232 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Script to ammend column data

4 New Member
Dear All,

I need to transfer data between two databases on two different SQL servers(both SQL server 2000).

I have a script that selects data from three tables on server1 and organises into the required format and stores in table A.

I do a bcp on table A and creates an output .txt file.

I use a bulk insert to table B. The error I get is a duplicate key violation and it comes from one column in table A which is a PK in table B.

I need to modify my script to alter data in column ID in table to say ID+a (e.g. 200 to 200a). ID is of datatype char. In this case I will not run into duplicate key problem with the bulk insert.

Thanks and regards
Kwame
Feb 28 '07 #1
5 1974
dorinbogdan
839 Recognized Expert Contributor
If you need to update all records in table A, on column name ID, then use:
Expand|Select|Wrap|Line Numbers
  1. Update A set ID = ID + 'a'
Mar 1 '07 #2
kma
4 New Member
Thanks a lot but the suggested solution gives me IDa in all therows of the column. What I want is somthing like this

Table B

ID
2
3
4
5

Transforms to

Table B
2a
3a
4a
5a

Thanks
Mar 1 '07 #3
kma
4 New Member
Thanks a lot but the suggested solution gives me IDa in all therows of the ID column. What I want is somthing like this

Table B

ID
2
3
4
5

Transforms to

Table B

ID
2a
3a
4a
5a

Thanks
Mar 1 '07 #4
dorinbogdan
839 Recognized Expert Contributor
Use it exactly as it reads: ID = ID + 'a'
If run from Query Analyzer
Expand|Select|Wrap|Line Numbers
  1. Update B Set ID = ID + 'a'
it will update column ID as appears in your expected result.
Mar 1 '07 #5
kma
4 New Member
thanks doringbogdan

When I run as you have given I get the ff error

Server: Msg 8152, Level 16, State 9, Line 1
String or binary data would be truncated.
The statement has been terminated.
Any help

Regards
Kwame
Mar 1 '07 #6

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

Similar topics

5
2627
by: Tim Morrison | last post by:
Is there any easy way to create a change script as illustrated below for all tables within a database? Right now I would have to create a seperate script for each table. I would like to be able to update the customers database while preserving their exisiting data. -------------------------------------------------------------------------------- BEGIN TRANSACTION
2
1563
by: MC | last post by:
I am writing a script to retrieve data records of MarinLif table. The problem is that i have a column MarinLif_Picture of type image so the insert is wrong in this way. How do i correct it? /*****MarinLIf TAble ********************/ DECLARE @ID INT DECLARE @typeID INT DECLARE @NAME NVARCHAR(50) Declare @scName nvarchar(50)
4
9669
by: D Newsham | last post by:
Hi, This javascript creates a table that has a header and side column that do not move while scrolling through the table. I need to convert this to vb script. Can anybody help, or do you have code in vb (asp) that would do the same thing? <html> <head> <title>Scrolling Grid Demo</title>
10
2560
by: shumaker | last post by:
I don't need a detailed description of a solution(although I wouldn't mind), but I am hoping someone could tell me in general the best path to go about accomplishing a task, since I don't know all the capabilities of what I have available. I can learn the details myself I think. I am trying to set this up to be as simple to use as possible since others will be importing data on a weekly or daily basis. I need to import some text files,...
4
17963
by: Kevin Murphy | last post by:
This is a tip for the record in case it helps somebody else in the future. I have an import script that relies on a stored procedure that runs as a trigger on inserts into a temporary table. The script looks like this: -- create table -- ... -- define procedure and trigger
2
3115
by: Muzzy | last post by:
Hi, I've used information on these newsgroups to build many pages. So I thought that now that I have my script working (something that I've been working on for about a week), I should post it so that it may help others. If posting this script is against the rules in this group then please accept my appologies. I developped this script so that I can add and remove rows in a table in which I have various input fields and I would use the...
3
1427
by: Amos0907 | last post by:
Dear All, I am a learner of Javascript. I got an assignment as below. Could anyone give me a suggestion for fixing the function of "onChangeColumn4()". The original requirement of the start date of this practice is 1985 09 20. When user click different year and different month, then the "Index Number" will display different number. (actually, every season is the same index number".) I used a data hierarchy approach to program it, but it...
7
3384
by: Mariusf | last post by:
I am a novice Perl programmer and need to change a perl script that I use to create web pages with thumbnail images and some text. Currently the script created a web page for each artist / category with all the thumb images below one another in the table. Thus the table has one column with a row for each image. I am trying to change the script to have 3 columns in the table in the end (first testing with second column as in the attached...
7
4203
by: Jaros³aw Kozik | last post by:
how to create script - update database development code using MSSQL 2000 Enterprise Manager i'm trying in this way all tasks -genetate sql script .... ( in this way I can generate only CREATE Database SCRIPT ... )
0
8896
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9451
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9421
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9333
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8328
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4771
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4942
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3395
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2284
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.