Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to add a column in this compare?

Author  Topic 

AdamWest
Constraint Violating Yak Guru

360 Posts

Posted - 2010-10-22 : 17:40:02
I have one table which is transacions. I includes a customerid number.
A process will add customers who are new so there is no problem there.
But the need is to then create a user row for this customerid.
A userid can be created with this custid and make the user name can be the customername appended with _User1. Now there only needs to be one of these users.

Table_a. Table_b Table_C

customerid customerid customerid
customer-name userid (created here)


Table_D

Customerid

(add a) reportid (always sb 'R12')


I presume this can be done in a SQL Query, I am not sure how one would do this.

Adam

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-10-23 : 01:42:13
you would be better off showing some sample data of how you want data in those tables. Its quite difficult to make out from your explanation above

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

AdamWest
Constraint Violating Yak Guru

360 Posts

Posted - 2010-10-25 : 11:01:28
OK this is a little easier. We seem to have 2 redundant tables for the moment. called 'users' in 2 databases. One db is called 'Securitydb' and the other is 'Spendanalyzer'

Spendanalyzer:
UserId (PK, Int, notnull)
Password (varchar(50), notnull)
FullName (varchar(100), notnull)
reports(varchar(50), null)

Securitydb:
UserName (PK, Varchar(50) notnull)
Password (varchar(50), notnull)
FullName (varchar(50), notnull)
reports(varchar(50), null)

How can I copy the rows from Securitydb to spendanalyzer, as an append. the new rows have been entered to Securitydb.


quote:
Originally posted by visakh16

you would be better off showing some sample data of how you want data in those tables. Its quite difficult to make out from your explanation above

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/



Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-10-27 : 13:51:49
but you dont have Username field in Spendanalyzer db. so where do you want to put the contents of username fields from securitydb? also is UserID identity field in Spendanalyzer? if not, how will you be generating the values? is there some sequence to be followed?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -