Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7414433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:05:59+00:00 2026-05-29T07:05:59+00:00

As this goes without saying, I’m a severe novice when it comes to T-SQL

  • 0

As this goes without saying, I’m a severe novice when it comes to T-SQL and using SSMSE isn’t my first option but I’m stuck with it and a poorly designed database. Essentially I’m trying to output the data from our current database so I can upload it to our new software and I need to get this data in manageable CSV files first.

I’m trying to move measurements associated with subjects in various studies but the data lies across several tables. The tables are as follows (primary keys listed first):

CREATE TABLE Study (StudyID int, StudyName nvarchar(50))

CREATE TABLE Subject (SubjectID int, SubjectName nvarchar(20), StudyID int)

CREATE TABLE Implant (ImplantID int, ImplantName nvarchar(255), StudyID int)

CREATE TABLE Measurement (MeasurementID int, SubjectID int, ImplantID int, 
                          Length float, Width float, Volume float, 
                          PerformDateTime datetime)

I know I’m new to databases but this topology really confused me. We have a lot of studies and I’d love to create an excel file for each study that organizes the data in the format for directly importing. To do that I would need to generate a CSV file for each study that looked like this:

CREATE TABLE ImportStudy (SubjectName, PerformDateTime, Length, Width, Volume)

It’s OK that the Subject Names would be repeated in the first column because that’s how the new software inserts it. Any help would be great and save me about a month or two of my life even if I have to use a WHERE StudyName LIKE N'ABC123' and enter each one. If anyone can help me add the T-SQL equivalent of an Object Oriented “For Each” loop that would be amazing. Thanks again for any help.

Best,
Jeff

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T07:06:00+00:00Added an answer on May 29, 2026 at 7:06 am

    I’m not 100% sure what you want but getting a CSV file is pretty easy. If you’d like to extract the data you specified, run a query similar to this and have Management Studio output the results to a CSV file:

    select Subject.SubjectName, 
           Measurement.PerformDateTime, 
           Measurement.Length, 
           Measurement.Width, 
           Measurement.Volume 
    From Study 
    inner join Subject on Study.StudyId = Subject.StudyId
    inner join Implant on Study.StudyId = Implant.StudyId
    inner join Measurement on Implant.ImplantId = Measurement.ImplantId
    

    What’s a bit strange with your schema is that you’ve linked Measurement to both Subjects and Implants. I’ve ignored the link from Subject to Measurement in the query above.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It goes almost without saying, this works perfectly in Chrome, Firefox, and Safari. IE
It goes without saying that using hard-coded, hex literal pointers is a disaster: int
This one goes round and round I know but I can't seem to find
I know this rather goes against the idea of enums, but is it possible
I have two forms. The first form is the mainForm, this never goes anywhere.
First off let me start by saying I am using CodeIgniter and the Facebook
Right, this code goes through a rather large multidimensional array (has about 28,000 rows
I have an XML that goes like this: <?xml version=1.0 encoding=utf-8 ?> <colors> <color
the Requirement in simple words goes like this. Its a charting Application ( kinda
Part of my code goes like this: while(1){ my $winmm = new Win32::MediaPlayer; $winmm->load('1.mp3');

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.