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
 Not sure how to copy rows

Author  Topic 

AdamWest
Constraint Violating Yak Guru

360 Posts

Posted - 2010-05-26 : 11:23:56
HI I have a security table that then is used by the SSRS and Silverlight reports.
I have one user named Jeff and I want to now allow a second user named Gary to have the exact same reports as Jeff.
How do I make such a copy?

UserName CustomerNumber CustomerID
Jeff NM01 21
Jeff F01 22
Jeff NADC01 7
Jeff NG01 8
Jeff NM01 9
Rich bhcc02 28
Jeff NMMC01 11
Jeff NMMC02 12
Jeff NMR01 13
Jeff NMR03 14
Jeff Northern 15
Jeff NR01 16
Jeff NRH01 17
Jeff NRH03 18
Debra IAD01 19
Debra IAH01 1
Debra IAD01 20
Debra IAH01 1
Debra IAH01 2

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-05-26 : 11:27:24
Try:
insert your_table
select
'Gary',
CustomerNumber,
CustomerID
from your_table
where UserName='Jeff'


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-05-26 : 11:28:07
To see what will happen you can execute the select without the insert part.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-05-26 : 11:29:19
insert into table(UserName ,CustomerNumber ,CustomerID)
select 'Gary', CustomerNumber ,CustomerID from table
where username='Jeff'

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-05-26 : 11:32:18
quote:
Originally posted by madhivanan

insert into table(UserName ,CustomerNumber ,CustomerID)
select 'Gary', CustomerNumber ,CustomerID from table
where username='Jeff'

Madhivanan

Failing to plan is Planning to fail


Your refresh-button is damaged?



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-05-26 : 11:33:14

Webfred is faster today

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

AdamWest
Constraint Violating Yak Guru

360 Posts

Posted - 2010-05-26 : 12:21:36
Yep, thanks again.
Go to Top of Page
   

- Advertisement -