TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
jayakrishnan Morayur
NA
193
258.3k
copy data from one table of database to another database
Mar 25 2011 3:21 AM
i have two databases with name "Student" and "Student1"
The "studentDetails" table is bellow
SdtId | StuName
|
numeric | varbinary(100)
(100) |
|
|
a Certificate name("stuCert") and Symmetric("stuKey") Key are exist
for encripting the datas in sql server
code for insert
@StdName NVARCHAR
(
50
)
@StdClass
NVARCHAR
(
50
)
ALTER
PROCEDURE
[dbo]
.
[StudentInsert]
NVARCHAR
(
50
)
,
BEGIN
DECLARE
@OMK
nvarchar
(
1000
)
DECLARE
@OSK
nvarchar
(
1000
)
DECLARE
@CMK
nvarchar
(
100
)
SET
@OMK
=
'OPEN MASTER KEY DECRYPTION BY PASSWORD =''abc'''
SET
@OSK
=
'OPEN SYMMETRIC KEY stuKey DECRYPTION BY CERTIFICATE stuCert'
SET
@CMK
=
'CLOSE MASTER KEY'
EXEC
(
@OMK
);
IF
@@error
=
0
BEGIN
EXEC
(
@OSK
);
INSERT
INTO
Student
VALUES
(
@StdName
,
ENCRYPTBYKEY
(
KEY_GUID
('
stuKey'
),
@StdClass
))
EXEC
(
@CMK
)
END
END
code for select
DECLARE
@openMasterKey
nvarchar
(
4000
);
SET
@openMasterKey
=
'OPEN MASTER KEY DECRYPTION BY PASSWORD =''abc'''
;
EXEC
(
@openMasterKey
);
IF
@@error
=
0
BEGIN
OPEN
SYMMETRIC
KEY
stuKey
DECRYPTION
BY
CERTIFICATE
stuCert
SELECT
dbo
.
Student1
.
StdId
,
dbo
.
Student1
.
StdName
,
cast
(
CONVERT
(
NVARCHAR
(
50
),
DECRYPTBYKEY
(
StdClass
))
as
NVARCHAR
(
50
))
AS
StdClass
FROM
dbo
.
Student1
END
i want to copy datas from table "studentDetails" from database "Student" to database "Student1"
please help me...
Reply
Answers (
4
)
select query for Encrypted data from another database
XML file data to perminent table in database