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
 Data Conversion Samples

Author  Topic 

cstokes91
Yak Posting Veteran

72 Posts

Posted - 2012-12-20 : 10:34:46
Hello,

I was hoping to get some sample scripts for doing data conversions. Basically, I will be going into a clients database and map all of their data to our database and tables. Does anyone have a sample script of something like this where it shows some of the syntax with sending data from one database to another and matching specific columns up etc etc.

Thanks for any help,

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-12-20 : 10:57:23
what are type of conversions you'll be doing? Is there a rule defined?

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

Go to Top of Page

cstokes91
Yak Posting Veteran

72 Posts

Posted - 2012-12-21 : 15:41:27
Basically mapping the data from their databases where when I put it in our databases it will match up...

ie fname = firstName in our database... but that is very limited. Like my last script to convert one table was

INSERT INTO [OurDatabaseName].[dbo].[OurTableName] (OurColumnName, OurColumnName2, OurColumnName3)
SELECT
TheirColumnName AS OurColumnName -- these columnms have same datatype
, CAST(TheirColumnName2 AS VARCHAR(120)) AS OurColumnName2
, TheirColumnName3 AS OurColumnName
FROM [TheirDataBase].[DBO].[TheirTableName]


This is a very basic example of the conversions I have done so far. Is there any other method that you would recommend looking into / script you can provide that might be easier on a bigger scale or more efficient?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-12-21 : 23:20:03
Nope. It has to be dealt with on a column by column basis. Create a mapping sheet between source and destination and then apply data conversion accordingly. You can deal it generically.

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

Go to Top of Page
   

- Advertisement -