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').

8 comments:

Unknown 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?

Anonymous 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

gethqnet said...

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

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

Unknown 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 !