Sunday, 21 October 2007

Migrating data from SPSS to SQL Server 2005

SQL Server 2005 has among Native SQL Server also OLEDB connection which enables you to import data to you favorite SPSS version.

Using SPSS Syntax you can with almost no haste import data - using T-Sql Query to SPSS.

[Code]

*sql->spss.

get data

/type=odbc
/connect='Driver={SQLServer};Server=My_server_name;Uid=My_User_name;Pwd=My_password;database=My_database'

/sql ='select id, name, cast(round(cast(datediff(day, BirthDate, getdate()) as float) / 365.25, 0, -1) as integer),(select max(date_time) from table1 where table1.date = date2) as Another_Date from table2 as t2 join table3 as t3 on t2.id = t3.id join table4 as t4 on t2.date = t4.id where t4.my_number = 1'
cache.

[/Code]


Where parameters My_server_name, My_username, My_password and My_database should be replaced.


SQL query should be enclosed in single aphostrophe ' and your SQL query should not contain any single quotes for enabling strings (eg.: where name = 'John').

12 comments:

Fishy said...

Great solution. One question, is there a work-around for the no "single quote" issue? Our database requires us to pull dates with single quotes because they were designed as alphanumeric. any thoughts?

Inti Soto said...

Could you help to do the process the other way around?

I mean, as you post suggests, what I need to do is to put data into SQL Server from SPSS, and I am looking for an alternative to automate the process of load 360+ SAV files into SQL Server.

Best regards,
Inti Soto

健康保寶 said...

You may be only one person in the world, but you may also be the world to one person.............................................

桃色花園 said...

一切與生俱來的天然贈品,時間最為寶貴........................................

gethqnet said...

Thanks for such a great post and the review, I am totally impressed! Keep stuff like this coming.
Michael Jackson

Anonymous said...

replica handbags
are alike with the needs of the fashion-savvy. Get affiliated and adjustment her admired replica bags
. designer replica handbags
are the latest addition. Some of the purses and the designer handbags
accord an electric appearance.

Microsoft Office 2007 said...

NEVERTHELESS, THE CIVIL LAW is and must be neutral about who has a more noble or rewarding faith. The breakaway parishes ought to win every Office 2010facet of the lawsuit not becauseMicrosoft Office 2010 their beliefs or their politics are better, Microsoft wordbut because both lawOffice 2007and equity, along with common sense, are on Microsoft Officetheir side.Microsoft Office 2007 Not only does Virginia state law (the Division Statute)Office 2007 keyexplicitly apply to just such a Office 2007 downloadsituation as now exists, but the history Office 2007 Professionalespecially of The Falls Church argues against the claims of Outlook 2010the Virginia Diocese with which theyMicrosoft outlookhave disassociated.Microsoft outlook 2010First, The Falls Church wasWindows 7 founded, formed, and developed long before the diocese, or the national Episcopal Church, even existed.

Buy HGH said...

finally found what i was looking for. it's helpful and solve my issue

Buy HGH

Pearson Airport Limo said...

prefer your provided solution, good job

Pearson Airport Limo

E-Clinical said...

i have followed your guidelines and thanks it really a helpful post for me

E-Clinical

jacob black said...

I discovered your blog site on google and check a few of your early posts. Continue to keep up the very good operate. I just additional up your RSS feed to my MSN News Reader. Seeking forward to reading more from you later on!…
Taxi accident

Evil said...

ahahah super post !