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

Script to ammend column data

4
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 1949
dorinbogdan
839 Expert 512MB
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
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
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 Expert 512MB
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
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
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...
2
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? ...
4
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...
10
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...
4
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. ...
2
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...
3
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...
7
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...
7
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...
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...
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?
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
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
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
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...

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.