-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSURVEY_Interest_Insert.sql
More file actions
1112 lines (994 loc) · 54.6 KB
/
SURVEY_Interest_Insert.sql
File metadata and controls
1112 lines (994 loc) · 54.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
USE DOGPAWS_MASTER
SELECT * FROM WK_1
INSERT INTO tblSURVEY(SurveyName, SurveyBeginDate, SurveyEnd, SurveyTypeID)
VALUES('DogPaws Interest Survey', 'May 22, 2020', 'September 22, 2020', (SELECT SurveyTypeID FROM tblSURVEY_TYPE WHERE SurveyTypeName = 'Interest')) -- sample end date and surveytypeid
/* inserts into tblQUESTION */
DECLARE @MC INT = (SELECT QuestionTypeID FROM tblQUESTION_TYPE WHERE QuestionTypeName = 'Multiple choice')
DECLARE @RateScale INT = (SELECT QuestionTypeID FROM tblQUESTION_TYPE WHERE QuestionTypeName = 'Rating scale')
DECLARE @LikertScale INT = (SELECT QuestionTypeID FROM tblQUESTION_TYPE WHERE QuestionTypeName = 'Likert Scale')
DECLARE @ShortAns INT = (SELECT QuestionTypeID FROM tblQUESTION_TYPE WHERE QuestionTypeName = 'Short answer')
DECLARE @Ranking INT = (SELECT QuestionTypeID FROM tblQUESTION_TYPE WHERE QuestionTypeName = 'Ranking')
INSERT INTO tblQUESTION(QuestionTypeID, QuestionName) -- NEW added demographic questions
VALUES(@ShortAns, 'What is your age?'),
(@MC, 'What is your gender?')
INSERT INTO tblQUESTION (QuestionTypeID, QuestionName) --Insert into tblQUESTION
VALUES
(@ShortAns, 'Timestamp'), -- q1
(@ShortAns, 'Email'), -- q2
(@MC, 'What is your class standing for the 2020-2021 school year?'), -- q3
(@MC, 'I am an... (resident status)'), -- q4
(@MC, 'I am... (housing status)'), -- q5
(@MC, 'Which statements below best describe you? (Select all that apply)'), -- q6
(@MC, 'What experiences or goals did you have for yourself when you came to UW?'), -- q7
(@MC, 'What struggles did you anticipate you would have during your first year?'), -- q8
(@MC, 'In what ways do you wish you had more support during your first year?'), -- q9
(@MC, 'Rate your level of agreement with the following statements: [I had a hard time finding a group that I feel I belong to.]'), -- Q10
(@MC, 'Rate your level of agreement with the following statements: [Joining an RSO helps me to make friends.]'), -- Q11
(@MC, 'Rate your level of agreement with the following statements: [I joined something I never thought I would join before coming to college.]'), -- Q12
(@LikertScale, 'Rate your level of agreement with the following statements: [I find it easier to make friends when we have shared common interests.]'), -- Q13
(@LikertScale, 'Rate your level of agreement with the following statements: [I find it hard to make friends at UW.]'), -- Q14
(@LikertScale, 'Rate your level of agreement with the following statements: [I initially felt lost coming when I came to UW.]'), -- Q15
(@LikertScale, 'Rate your level of agreement with the following statements: [I find it easy to form study groups.]'), -- Q16
(@LikertScale, 'Rate your level of agreement with the following statements: [I have a lot of friends from class or study groups.]'), -- Q17
(@ShortAns, 'What are some factors that made you join the RSO(s) you are a part of on campus? (If you are not in an RSO, please indicate N/A)'), -- q18
(@ShortAns, 'What are some factors that have prevented you or discouraged you from joining an RSO on campus? (If you are in an RSO, please indicate N/A)'), -- q19
(@MC, 'What platform(s) do you use to keep track of events and RSO? (Select all that apply)'), --Question 20 (multi-valued)
(@MC, 'What are some of the programs that you have found helpful in assisting you to find a community at UW? (Select all that apply)'), -- Q21 (multi-valued)
(@MC, 'I am... (major status)'), --Question 22
(@MC, 'My major is...'), --Question 23
(@MC, 'Which of the following platforms have you interacted with to network or search for a job or internship? (Select all that apply)'), -- Q24
(@LikertScale, 'Rate your level of agreement with the following statements: [I have a hard time finding my passion and my desired major.]'), --Question 25
(@LikertScale, 'Rate your level of agreement with the following statements: [I have a hard time getting an internship.]'), --Question 26
(@LikertScale, 'Rate your level of agreement with the following statements: [I have a hard time connecting with people within the industry.]'), --Question 27
(@LikertScale, 'Rate your level of agreement with the following statements: [Career Service provides adequate resources for me to succeed.]'), --Question 28
(@LikertScale, 'Rate your level of agreement with the following statements: [I feel prepared to find internships.]'), --Question 29
(@LikertScale, 'Rate your level of agreement with the following statements: [I have resources to get trustworthy feedback on my resumes/cover letters.]'), --Question 30
(@MC, 'Can we contact you for more information?'), --Question 31
(@MC, 'Are you interested in joining the DOGPAWS team?'), --Question 32
(@ShortAns, 'Additionally, please leave your preferred first and last name here if you answered yes to either of the first two questions asked on this page (format: Harry Husky):'); -- q33
DECLARE @Question_1 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'Timestamp')
DECLARE @Question_2 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'Email')
DECLARE @Question_3 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'What is your class standing for the 2020-2021 school year?')
DECLARE @Question_4 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'I am an... (resident status)')
DECLARE @Question_5 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'I am... (housing status)')
DECLARE @Question_6 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'Which statements below best describe you? (Select all that apply)')
DECLARE @Question_7 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'What experiences or goals did you have for yourself when you came to UW?')
DECLARE @Question_8 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'What struggles did you anticipate you would have during your first year?')
DECLARE @Question_9 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'In what ways do you wish you had more support during your first year?')
DECLARE @Question_10 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'Rate your level of agreement with the following statements: [I had a hard time finding a group that I feel I belong to.]');
DECLARE @Question_11 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'Rate your level of agreement with the following statements: [Joining an RSO helps me to make friends.]');
DECLARE @Question_12 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'Rate your level of agreement with the following statements: [I joined something I never thought I would join before coming to college.]');
DECLARE @Question_13 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'Rate your level of agreement with the following statements: [I find it easier to make friends when we have shared common interests.]')
DECLARE @Question_14 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'Rate your level of agreement with the following statements: [I find it hard to make friends at UW.]')
DECLARE @Question_15 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'Rate your level of agreement with the following statements: [I initially felt lost coming when I came to UW.]')
DECLARE @Question_16 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'Rate your level of agreement with the following statements: [I find it easy to form study groups.]')
DECLARE @Question_17 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'Rate your level of agreement with the following statements: [I have a lot of friends from class or study groups.]')
DECLARE @Question_18 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'What are some factors that made you join the RSO(s) you are a part of on campus? (If you are not in an RSO, please indicate N/A)')
DECLARE @Question_19 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'What are some factors that have prevented you or discouraged you from joining an RSO on campus? (If you are in an RSO, please indicate N/A)')
DECLARE @Question_20 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'What platform(s) do you use to keep track of events and RSO? (Select all that apply)')
DECLARE @Question_21 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'What are some of the programs that you have found helpful in assisting you to find a community at UW? (Select all that apply)')
DECLARE @Question_22 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'I am... (major status)');
DECLARE @Question_23 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'My major is...');
DECLARE @Question_24 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'Which of the following platforms have you interacted with to network or search for a job or internship? (Select all that apply)');
DECLARE @Question_25 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'Rate your level of agreement with the following statements: [I have a hard time finding my passion and my desired major.]');
DECLARE @Question_26 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'Rate your level of agreement with the following statements: [I have a hard time getting an internship.]');
DECLARE @Question_27 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'Rate your level of agreement with the following statements: [I have a hard time connecting with people within the industry.]');
DECLARE @Question_28 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'Rate your level of agreement with the following statements: [Career Service provides adequate resources for me to succeed.]');
DECLARE @Question_29 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'Rate your level of agreement with the following statements: [I feel prepared to find internships.]');
DECLARE @Question_30 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'Rate your level of agreement with the following statements: [I have resources to get trustworthy feedback on my resumes/cover letters.]');
DECLARE @Question_31 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'Can we contact you for more information?');
DECLARE @Question_32 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'Are you interested in joining the DOGPAWS team?');
DECLARE @Question_33 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName LIKE '%Harry Husky%')
-- NEW demographic questions
DECLARE @Question_Age INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'What is your age?')
DECLARE @Question_Gender INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'What is your gender?')
/* inserts into tblSURVEY_QUESTION*/
DECLARE @SurvID INT = (SELECT SurveyID FROM tblSURVEY WHERE SurveyName = 'DogPaws Interest Survey')
-- NEW demographic questions
INSERT INTO tblSURVEY_QUESTION (SurveyID, QuestionID, QuestionNumber)
VALUES(@SurvID, @Question_Age, 34), (@SurvID, @Question_Gender, 35)
INSERT INTO tblSURVEY_QUESTION (SurveyID, QuestionID, QuestionNumber)
Values
(@SurvID, @Question_1, 1),
(@SurvID, @Question_2, 2),
(@SurvID, @Question_3, 3),
(@SurvID, @Question_4, 4),
(@SurvID, @Question_5, 5),
(@SurvID, @Question_6, 6),
(@SurvID, @Question_7, 7),
(@SurvID, @Question_8, 8),
(@SurvID, @Question_9, 9),
(@SurvID, @Question_10, 10),
(@SurvID, @Question_11, 11),
(@SurvID, @Question_12, 12),
(@SurvID, @Question_13, 13),
(@SurvID, @Question_14, 14),
(@SurvID, @Question_15, 15),
(@SurvID, @Question_16, 16),
(@SurvID, @Question_17, 17),
(@SurvID, @Question_18, 18),
(@SurvID, @Question_19, 19),
(@SurvID, @Question_20, 20),
(@SurvID, @Question_21, 21),
(@SurvID, @Question_22, 22),
(@SurvID, @Question_23, 23),
(@SurvID, @Question_24, 24),
(@SurvID, @Question_25, 25),
(@SurvID, @Question_26, 26),
(@SurvID, @Question_27, 27),
(@SurvID, @Question_28, 28),
(@SurvID, @Question_29, 29),
(@SurvID, @Question_30, 30),
(@SurvID, @Question_31, 31),
(@SurvID, @Question_32, 32),
(@SurvID, @Question_33, 33);
/* ***************************************************************** */
EXEC uspInsertFromCSV @SurveyName = 'DogPaws Interest Survey'
GO
ALTER PROC uspInsertFromCSV
@SurveyName varchar(100)
AS
BEGIN
DECLARE @RowNum INT = 1
DECLARE @TotalRows INT = (SELECT COUNT(*) FROM WK_1)
DECLARE @F varchar(50), @L varchar(50), @Email varchar(100), @Temp varchar(100)
DECLARE @ResponseDateTime DateTime = (Select Question_1 From WK_1 Where ResponseID = @RowNum),
@ProfilePK INT
DECLARE @SurveyID INT = (SELECT SurveyID FROM tblSURVEY WHERE SurveyName = 'DogPaws Interest Survey')
--PRINT(@SurveyID)
WHILE @RowNum <= @TotalRows
BEGIN
SET @Temp = (SELECT Question_33 FROM WK_1 WHERE ResponseID = @RowNum)
IF @Temp IS NULL OR @Temp = 'N/A'
BEGIN
SET @F = 'anon'
SET @L = 'anon'
END
ELSE
BEGIN
SET @F = SUBSTRING(@Temp, 1, CHARINDEX(' ', @Temp) - 1)
SET @L = SUBSTRING(@Temp, CHARINDEX(' ', @Temp) + 1, LEN(@Temp))
END
SET @Email = (SELECT Question_2 FROM WK_1 WHERE ResponseID = @RowNum)
IF NOT EXISTS (SELECT ProfileID FROM tblPROFILE WHERE Email = @Email)
BEGIN
INSERT INTO tblPROFILE(Fname, Lname, Email)
VALUES(@F, @L, @Email)
END
ELSE
BEGIN
SET @RowNum = @RowNum + 1
CONTINUE
END
SET @ProfilePK = (SELECT ProfileID FROM tblPROFILE WHERE Email = @Email)
--PRINT(@ProfilePK)
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES(@ProfilePK, @ResponseDateTime, @Email)
DECLARE @RespID INT = SCOPE_IDENTITY()
--PRINT(@RespID)
--PRINT('Inserted into response')
DECLARE @QuestID INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'Email')
DECLARE @SurvQuestID INT = (SELECT SurveyQuestionID FROM tblSURVEY_QUESTION
WHERE SurveyID = @SurveyID AND QuestionID = @QuestID)
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SurvQuestID, @RespID)
--PRINT('Inserted into SQR')
/*** NEW demographic questions */
DECLARE @Age INT = TRY_PARSE((SELECT Question_34 FROM WK_1 WHERE ResponseID = @RowNum) AS INT)
IF (@Age IS NOT NULL)
BEGIN
UPDATE tblPROFILE
SET Age = @Age WHERE ProfileID = @ProfilePK
END
DECLARE @Gender varchar(20) = (SELECT Question_35 FROM WK_1 WHERE ResponseID = @RowNum)
IF (@Gender IS NOT NULL)
BEGIN
UPDATE tblPROFILE
SET Gender = @Gender WHERE ProfileID = @ProfilePK
END
/* Q 3-5 */
DECLARE @Yr varchar(50), @StudType varchar(50), @Housing varchar(50),
@DT_ID1 INT, @DT_ID2 INT, @DT_ID3 INT, @D_ID INT, @R_ID INT, @Q_ID INT, @SQ_ID INT
SET @Yr = (SELECT Question_3 FROM WK_1 WHERE ResponseID = @RowNum)
SET @StudType = (SELECT Question_4 FROM WK_1 WHERE ResponseID = @RowNum)
SET @Housing = (SELECT Question_5 FROM WK_1 WHERE ResponseID = @RowNum)
-- ****** getting detail_typeID -> will have to populate detail_type table / figure out how detail types are categorized
SET @DT_ID1 = (
SELECT DetailTypeID
FROM tblDETAIL_TYPE
WHERE DetailTypeName = 'student year'
)
SET @DT_ID2 = (
SELECT DetailTypeID
FROM tblDETAIL_TYPE
WHERE DetailTypeName = 'resident status'
)
SET @DT_ID3 = (
SELECT DetailTypeID
FROM tblDETAIL_TYPE
WHERE DetailTypeName = 'housing status'
)
-- insert response for q3 into detail table
INSERT INTO tblDETAIL(DetailName, DetailTypeID)
VALUES(@Yr, @DT_ID1)
SET @D_ID = (SELECT SCOPE_IDENTITY())
-- q3
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES(@ProfilePK, @ResponseDateTime, @Yr)
-- getting responseID
SET @R_ID = (SELECT SCOPE_IDENTITY())
SET @Q_ID = (SELECT QuestionID FROM tblQUESTION
WHERE QuestionName = 'What is your class standing for the 2020-2021 school year?')
SET @SQ_ID = (
SELECT SurveyQuestionID
FROM tblSURVEY_QUESTION
WHERE SurveyID = @SurveyID
AND QuestionID = @Q_ID
)
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @R_ID)
-- insert into Profile_detail
INSERT INTO tblPROFILE_DETAIL(ProfileID, DetailID)
VALUES(@ProfilePK, @D_ID)
-- repeat for q4
INSERT INTO tblDETAIL(DetailName, DetailTypeID)
VALUES(@StudType, @DT_ID2)
SET @D_ID = (SELECT SCOPE_IDENTITY())
INSERT INTO tblPROFILE_DETAIL(ProfileID, DetailID)
VALUES(@ProfilePK, @D_ID)
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES(@ProfilePK, @ResponseDateTime, @StudType)
SET @R_ID = (SELECT SCOPE_IDENTITY())
SET @Q_ID = (SELECT QuestionID FROM tblQUESTION
WHERE QuestionName = 'I am an... (resident status)')
SET @SQ_ID = (
SELECT SurveyQuestionID
FROM tblSURVEY_QUESTION
WHERE SurveyID = @SurveyID
AND QuestionID = @Q_ID
)
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @R_ID)
-- repeat for q5
INSERT INTO tblDETAIL(DetailName, DetailTypeID)
VALUES(@Housing, @DT_ID3)
SET @D_ID = (SELECT SCOPE_IDENTITY())
INSERT INTO tblPROFILE_DETAIL(ProfileID, DetailID)
VALUES(@ProfilePK, @D_ID)
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES(@ProfilePK, @ResponseDateTime, @Housing)
SET @R_ID = (SELECT SCOPE_IDENTITY())
SET @Q_ID = (SELECT QuestionID FROM tblQUESTION
WHERE QuestionName = 'I am... (housing status)')
SET @SQ_ID = (
SELECT SurveyQuestionID
FROM tblSURVEY_QUESTION
WHERE SurveyID = @SurveyID
AND QuestionID = @Q_ID
)
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @R_ID)
/* Q6 */
DECLARE @Q6 varchar(max) = (SELECT Question_6 FROM WK_1 WHERE ResponseID = @RowNum)
SET @Q_ID = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'Which statements below best describe you? (Select all that apply)')
SET @SQ_ID = (SELECT SurveyQuestionID FROM tblSURVEY_QUESTION WHERE SurveyID = @SurveyID AND QuestionID = @Q_ID)
IF @Q6 = 'None of the above'
BEGIN
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'None of the above')
SET @RespID = SCOPE_IDENTITY()
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
END
ELSE
BEGIN
IF @Q6 LIKE '%participate in one or more Registered Student Organization%'
BEGIN
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'I participate in one or more Registered Student Organization(s) on campus')
SET @RespID = SCOPE_IDENTITY()
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
END
IF @Q6 LIKE '%officer%'
BEGIN
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'I am an officer in one or more Registered Student Organization(s) on campus')
SET @RespID = SCOPE_IDENTITY()
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
END
IF @Q6 LIKE '%sports%'
BEGIN
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'I participate in one or more sports teams (varsity or club)')
SET @RespID = SCOPE_IDENTITY()
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
END
IF @Q6 LIKE '%Greek%'
BEGIN
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'I am in the Greek System')
SET @RespID = SCOPE_IDENTITY()
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
END
IF @Q6 LIKE '%Fraternity%'
BEGIN
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'I am in a major-related Fraternity (i.e. Professional, Academic, etc.)')
SET @RespID = SCOPE_IDENTITY()
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
END
/* IF [user typed response] */
END
/* Q7 */
DECLARE @Q7 varchar(max) = (SELECT Question_7 FROM WK_1 WHERE ResponseID = @RowNum)
SET @Q_ID = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'What experiences or goals did you have for yourself when you came to UW?')
SET @SQ_ID = (SELECT SurveyQuestionID FROM tblSURVEY_QUESTION WHERE SurveyID = @SurveyID AND QuestionID = @Q_ID)
IF @Q7 = 'Meet new people'
BEGIN
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'Meet new people')
SET @RespID = SCOPE_IDENTITY()
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
END
IF @Q7 LIKE '%my major%'
BEGIN
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'Get into my major')
SET @RespID = SCOPE_IDENTITY()
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
END
IF @Q7 LIKE 'Join a club%'
BEGIN
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'Join a club or RSO')
SET @RespID = SCOPE_IDENTITY()
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
END
IF @Q7 LIKE 'Join a fraternity%'
BEGIN
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'Join a fraternity or sorority')
SET @RespID = SCOPE_IDENTITY()
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
END
IF @Q7 LIKE '%adult%'
BEGIN
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'Learn how to be an adult (i.e. budgeting, time-management, cooking, responsibility)')
SET @RespID = SCOPE_IDENTITY()
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
END
IF @Q7 LIKE '%connections%'
BEGIN
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'Make connections with professors')
SET @RespID = SCOPE_IDENTITY()
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
END
IF @Q7 LIKE '%Ph.D.%'
BEGIN
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'Get into a Master''s or Ph.D. program')
SET @RespID = SCOPE_IDENTITY()
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
END
IF @Q7 LIKE '%research%'
BEGIN
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'Doing research as an undergrad')
SET @RespID = SCOPE_IDENTITY()
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
END
IF @Q7 LIKE '%figure out%'
BEGIN
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'Figure out what you want to do with your life')
SET @RespID = SCOPE_IDENTITY()
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
END
IF @Q7 LIKE '%partner%'
BEGIN
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'Find a partner')
SET @RespID = SCOPE_IDENTITY()
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
END
IF @Q7 LIKE '%party%'
BEGIN
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'Go to a party')
SET @RespID = SCOPE_IDENTITY()
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
END
/* IF [user typed response] */
/* Q8 */
DECLARE @Q8 varchar(max) = (SELECT Question_8 FROM WK_1 WHERE ResponseID = @RowNum)
SET @Q_ID = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'What struggles did you anticipate you would have during your first year?')
SET @SQ_ID = (SELECT SurveyQuestionID FROM tblSURVEY_QUESTION WHERE SurveyID = @SurveyID AND QuestionID = @Q_ID)
--PRINT(@Q8)
IF @Q8 LIKE '%course load%'
BEGIN
--PRINT(CONCAT('Q8 1, ', @RowNum))
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES(@ProfilePK, @ResponseDateTime, 'Course load, homework, assignments')
SET @RespID = (SELECT SCOPE_IDENTITY())
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
END
IF @Q8 LIKE '%exams%'
BEGIN
--PRINT(CONCAT('Q8 2, ', @RowNum))
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES(@ProfilePK, @ResponseDateTime, 'Exams')
SET @RespID = (SELECT SCOPE_IDENTITY())
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
END
IF @Q8 LIKE '%Having a difficult major%'
BEGIN
--PRINT(CONCAT('Q8 3, ', @RowNum))
--PRINT('Q8 IF')
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES(@ProfilePK, @ResponseDateTime, 'Having a difficult major')
SET @RespID = (SELECT SCOPE_IDENTITY())
--PRINT(@RespID)
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
END
IF @Q8 LIKE '%Getting into a difficult major%'
BEGIN
--PRINT(CONCAT('Q8 4, ', @RowNum))
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES(@ProfilePK, @ResponseDateTime, 'Getting into a difficult major')
SET @RespID = (SELECT SCOPE_IDENTITY())
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
END
IF @Q8 LIKE '%Making friends%'
BEGIN
--PRINT(CONCAT('Q8 5, ', @RowNum))
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES(@ProfilePK, @ResponseDateTime, 'Making friends')
SET @RespID = (SELECT SCOPE_IDENTITY())
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
END
IF @Q8 LIKE '%Finding a club that fits your interests%'
BEGIN
--PRINT(CONCAT('Q8 6, ', @RowNum))
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES(@ProfilePK, @ResponseDateTime, 'Finding a club that fits your interests')
SET @RespID = (SELECT SCOPE_IDENTITY())
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
END
IF @Q8 LIKE '%Finding community%'
BEGIN
--PRINT(CONCAT('Q8 7, ', @RowNum))
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES(@ProfilePK, @ResponseDateTime, 'Finding community')
SET @RespID = (SELECT SCOPE_IDENTITY())
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
END
IF @Q8 LIKE '%Adapting to living on your own%'
BEGIN
--PRINT(CONCAT('Q8 8, ', @RowNum))
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES(@ProfilePK, @ResponseDateTime, 'Adapting to living on your own')
SET @RespID = (SELECT SCOPE_IDENTITY())
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
END
--PRINT(CONCAT(@Q8, ' end'))
-- parse user input response
/* Q9 */
DECLARE @Q9 varchar(max) = (SELECT Question_9 FROM WK_1 WHERE ResponseID = @RowNum)
SET @Q_ID = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'In what ways do you wish you had more support during your first year?')
SET @SQ_ID = (SELECT SurveyQuestionID FROM tblSURVEY_QUESTION WHERE SurveyID = @SurveyID AND QuestionID = @Q_ID)
--PRINT(@Q9)
IF @Q9 LIKE '%access to RSOs%'
BEGIN
--PRINT(CONCAT('Q9 1, ', @RowNum))
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'Easier access to RSOs and their events throughout the year')
SET @RespID = (SELECT SCOPE_IDENTITY())
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
END
IF @Q9 LIKE '%commute to campus%'
BEGIN
--PRINT(CONCAT('Q9 2, ', @RowNum))
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'Finding someone to commute to campus with')
SET @RespID = (SELECT SCOPE_IDENTITY())
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
END
IF @Q9 LIKE '%internships%'
BEGIN
--PRINT(CONCAT('Q9 3, ', @RowNum))
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'Career development opportunities (i.e. networking, finding internships)')
SET @RespID = (SELECT SCOPE_IDENTITY())
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
END
IF @Q9 LIKE '%roommate%'
BEGIN
--PRINT(CONCAT('Q9 4, ', @RowNum))
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'Finding a roommate you can get along')
SET @RespID = (SELECT SCOPE_IDENTITY())
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
END
IF @Q9 LIKE '%community%'
BEGIN
--PRINT(CONCAT('Q9 5, ', @RowNum))
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'Developing a community')
SET @RespID = (SELECT SCOPE_IDENTITY())
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
END
IF @Q9 LIKE '%study groups%'
BEGIN
--PRINT(CONCAT('Q9 6, ', @RowNum))
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'Creating study groups')
SET @RespID = (SELECT SCOPE_IDENTITY())
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
END
IF @Q9 LIKE '%connections%'
BEGIN
--PRINT(CONCAT('Q9 7, ', @RowNum))
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'Making connections during class')
SET @RespID = (SELECT SCOPE_IDENTITY())
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
END
IF @Q9 LIKE '%academic resources%'
BEGIN
--PRINT(CONCAT('Q9 8, ', @RowNum))
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'Knowing what academic resources are available')
SET @RespID = (SELECT SCOPE_IDENTITY())
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
END
IF @Q9 LIKE '%research%'
BEGIN
--PRINT(CONCAT('Q9 9, ', @RowNum))
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'Finding research opportunities')
SET @RespID = (SELECT SCOPE_IDENTITY())
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
END
IF @Q9 LIKE '%majors%'
BEGIN
--PRINT(CONCAT('Q9 10, ', @RowNum))
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'Exploring different majors')
SET @RespID = (SELECT SCOPE_IDENTITY())
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
END
--PRINT(CONCAT(@Q9, ' end'))
/* Insert response for question 10 - 12 */
DECLARE @Question_10 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'Rate your level of agreement with the following statements: [I had a hard time finding a group that I feel I belong to.]');
DECLARE @Question_11 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'Rate your level of agreement with the following statements: [Joining an RSO helps me to make friends.]');
DECLARE @Question_12 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'Rate your level of agreement with the following statements: [I joined something I never thought I would join before coming to college.]');
-- For question 10
-- Insert into tblRESPONSE
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName) VALUES
(@ProfilePK, @ResponseDateTime, (SELECT Question_10 FROM WK_1 WHERE ResponseID = @RowNum))
-- Insert into tblSURVEY_QUESTION_RESPONSE
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID) VALUES
((SELECT SurveyQuestionID FROM tblSURVEY_QUESTION WHERE SurveyID = @SurveyID AND QuestionID = @Question_10), SCOPE_IDENTITY())
-- For question 11
-- Insert into tblRESPONSE
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName) VALUES
(@ProfilePK, @ResponseDateTime, (SELECT Question_11 FROM WK_1 WHERE ResponseID = @RowNum))
-- Insert into tblSURVEY_QUESTION_RESPONSE
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID) VALUES
((SELECT SurveyQuestionID FROM tblSURVEY_QUESTION WHERE SurveyID = @SurveyID AND QuestionID = @Question_11), SCOPE_IDENTITY())
-- For question 12
-- Insert into tblRESPONSE
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName) VALUES
(@ProfilePK, @ResponseDateTime, (SELECT Question_12 FROM WK_1 WHERE ResponseID = @RowNum))
-- Insert into tblSURVEY_QUESTION_RESPONSE
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID) VALUES
((SELECT SurveyQuestionID FROM tblSURVEY_QUESTION WHERE SurveyID = @SurveyID AND QuestionID = @Question_12), SCOPE_IDENTITY())
-- Question 13-17
DECLARE @Q13_String VARCHAR(500) = 'Rate your level of agreement with the following statements: [I find it easier to make friends when we have shared common interests.]'
DECLARE @Q14_String VARCHAR(500) = 'Rate your level of agreement with the following statements: [I find it hard to make friends at UW.]'
DECLARE @Q15_String VARCHAR(500) = 'Rate your level of agreement with the following statements: [I initially felt lost coming when I came to UW.]'
DECLARE @Q16_String VARCHAR(500) = 'Rate your level of agreement with the following statements: [I find it easy to form study groups.]'
DECLARE @Q17_String VARCHAR(500) = 'Rate your level of agreement with the following statements: [I have a lot of friends from class or study groups.]'
DECLARE @Q13 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = @Q13_String)
DECLARE @Q14 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = @Q14_String)
DECLARE @Q15 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = @Q15_String)
DECLARE @Q16 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = @Q16_String)
DECLARE @Q17 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = @Q17_String)
-- 13-17 Response
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES(@ProfilePK, @ResponseDateTime, (SELECT Question_13 FROM WK_1 WHERE ResponseID = @RowNum)),
(@ProfilePK, @ResponseDateTime, (SELECT Question_14 FROM WK_1 WHERE ResponseID = @RowNum)),
(@ProfilePK, @ResponseDateTime, (SELECT Question_15 FROM WK_1 WHERE ResponseID = @RowNum)),
(@ProfilePK, @ResponseDateTime, (SELECT Question_16 FROM WK_1 WHERE ResponseID = @RowNum)),
(@ProfilePK, @ResponseDateTime, (SELECT Question_17 FROM WK_1 WHERE ResponseID = @RowNum))
-- 13-17 Survey_Question_Response
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES((SELECT SurveyQuestionID FROM tblSURVEY_QUESTION WHERE SurveyID = @SurveyID AND QuestionID = @Q13), SCOPE_IDENTITY()),
((SELECT SurveyQuestionID FROM tblSURVEY_QUESTION WHERE SurveyID = @SurveyID AND QuestionID = @Q14), SCOPE_IDENTITY()),
((SELECT SurveyQuestionID FROM tblSURVEY_QUESTION WHERE SurveyID = @SurveyID AND QuestionID = @Q15), SCOPE_IDENTITY()),
((SELECT SurveyQuestionID FROM tblSURVEY_QUESTION WHERE SurveyID = @SurveyID AND QuestionID = @Q16), SCOPE_IDENTITY()),
((SELECT SurveyQuestionID FROM tblSURVEY_QUESTION WHERE SurveyID = @SurveyID AND QuestionID = @Q17), SCOPE_IDENTITY())
DECLARE @Q18 varchar(max) = (SELECT Question_18 FROM WK_1 WHERE ResponseID = @RowNum)
SET @Q_ID = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'What are some factors that made you join the RSO(s) you are a part of on campus? (If you are not in an RSO, please indicate N/A)')
SET @SQ_ID = (SELECT SurveyQuestionID FROM tblSURVEY_QUESTION WHERE SurveyID = @SurveyID AND QuestionID = @Q_ID)
IF @Q18 <> ''
BEGIN
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, @Q18)
SET @RespID = (SELECT SCOPE_IDENTITY())
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
--PRINT('QUESTION 18')
END
DECLARE @Q19 varchar(max) = (SELECT Question_19 FROM WK_1 WHERE ResponseID = @RowNum)
SET @Q_ID = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'What are some factors that have prevented you or discouraged you from joining an RSO on campus? (If you are in an RSO, please indicate N/A)')
SET @SQ_ID = (SELECT SurveyQuestionID FROM tblSURVEY_QUESTION WHERE SurveyID = @SurveyID AND QuestionID = @Q_ID)
IF @Q19 <> ''
BEGIN
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, @Q19)
SET @R_ID = (SELECT SCOPE_IDENTITY())
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @R_ID)
--PRINT('QUESTION 19')
END
-- Question 20
DECLARE @Q20 varchar(max) = (SELECT Question_20 FROM WK_1 WHERE ResponseID = @RowNum)
SET @Q_ID = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'What platform(s) do you use to keep track of events and RSO? (Select all that apply)');
SET @SQ_ID = (SELECT SurveyQuestionID FROM tblSURVEY_QUESTION WHERE SurveyID = @SurveyID AND QuestionID = @Q_ID);
IF @Q20 = 'Not Applicable (I am not in an RSO)'
BEGIN
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'Not Applicable (I am not in an RSO)')
SET @RespID = SCOPE_IDENTITY()
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
--PRINT('QUESTION 20')
END
ELSE
BEGIN
IF @Q20 LIKE '%Facebook%'
BEGIN
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'Facebook')
SET @RespID = SCOPE_IDENTITY()
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
--PRINT('QUESTION 20')
END
IF @Q20 LIKE '%RSO''s Website%'
BEGIN
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'RSO''S Website')
SET @RespID = SCOPE_IDENTITY()
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
--PRINT('QUESTION 20')
END
IF @Q20 LIKE '%Email%'
BEGIN
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'Email')
SET @RespID = SCOPE_IDENTITY()
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
--PRINT('QUESTION 20')
END
/* IF [user typed response] */
END
-- Question 21
DECLARE @Q21 VARCHAR(MAX) = (SELECT Question_21 FROM WK_1 WHERE ResponseID = @RowNum)
SET @Q_ID = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'What are some of the programs that you have found helpful in assisting you to find a community at UW? (Select all that apply)');
SET @SQ_ID = (SELECT SurveyQuestionID FROM tblSURVEY_QUESTION WHERE SurveyID = @SurveyID AND QuestionID = @Q_ID);
BEGIN
IF @Q21 LIKE '%Advising & Orientation%'
BEGIN
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'Advising & Orientation')
SET @RespID = SCOPE_IDENTITY()
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
--PRINT('QUESTION 21')
END
IF @Q21 LIKE '%Dawg Daze%'
BEGIN
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'Dawg Daze')
SET @RespID = SCOPE_IDENTITY()
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
--PRINT('QUESTION 21')
END
IF @Q21 LIKE '%Facebook Groups%'
BEGIN
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'Facebook Groups')
SET @RespID = SCOPE_IDENTITY()
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
--PRINT('QUESTION 21')
END
IF @Q21 LIKE '%Posters around campus%'
BEGIN
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'Posters around campus')
SET @RespID = SCOPE_IDENTITY()
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
--PRINT('QUESTION 21')
END
-- Common User Typed Responses (Other: '')
IF @Q21 LIKE '%Class%'
BEGIN
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'Classes')
SET @RespID = SCOPE_IDENTITY()
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
--PRINT('QUESTION 21')
END
IF @Q21 LIKE '%Work%'
BEGIN
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'Working on or off campus')
SET @RespID = SCOPE_IDENTITY()
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
--PRINT('QUESTION 21')
END
IF @Q21 LIKE '%Dorm%'
BEGIN
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'Dorm Life')
SET @RespID = SCOPE_IDENTITY()
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
--PRINT('QUESTION 21')
END
IF @Q21 LIKE '%Common spaces%'
BEGIN
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'Common gathering areas')
SET @RespID = SCOPE_IDENTITY()
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
--PRINT('QUESTION 21')
END
IF @Q21 LIKE '%Club%'
BEGIN
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'Joining clubs')
SET @RespID = SCOPE_IDENTITY()
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
--PRINT('QUESTION 21')
END
IF @Q21 LIKE '%None%'
BEGIN
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'None of the above')
SET @RespID = SCOPE_IDENTITY()
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
--PRINT('QUESTION 21')
END
IF @Q21 LIKE '%Roommate%'
BEGIN
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'Roommate search and activities')
SET @RespID = SCOPE_IDENTITY()
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
--PRINT('QUESTION 21')
END
IF @Q21 LIKE '%RSO%'
BEGIN
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'Joining RSOs')
SET @RespID = SCOPE_IDENTITY()
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
--PRINT('QUESTION 21')
END
IF @Q21 LIKE '%Website%'
BEGIN
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'Utilizing school websites and resources')
SET @RespID = SCOPE_IDENTITY()
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
--PRINT('QUESTION 21')
END
IF @Q21 LIKE '%Fair%'
BEGIN
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, 'Attending RSO fairs or other school fairs')
SET @RespID = SCOPE_IDENTITY()
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID)
VALUES(@SQ_ID, @RespID)
--PRINT('QUESTION 21')
END
-- Extra IF [User Typed Response(s)]
-- Didn't create an IF/Else case based on "None of the above" answers since there may be other responses.
/* Q24 */
DECLARE @Question_24 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'Which of the following platforms have you interacted with to network or search for a job or internship? (Select all that apply)');
-- Create a temporary table to store string_split values with PRIMARY KEY for lookup
CREATE TABLE #TempQ24Placeholder (
ItemID int PRIMARY KEY IDENTITY(1,1),
Item varchar(500)
)
-- Get the Q24 reponse
DECLARE @Q24 varchar(max) = (SELECT Question_24 FROM WK_1 WHERE ResponseID = @RowNum)
-- Insert into temporary table, exclude empty values
INSERT INTO #TempQ24Placeholder(Item)
SELECT * FROM STRING_SPLIT(@Q24, ',') WHERE value <> ''
-- Declare variables needed for the while loop
DECLARE @Q24TotalRows int = (SELECT COUNT(*) FROM #TempQ24Placeholder)
DECLARE @Q24CurRowNum int = 1
WHILE @Q24CurRowNum <= @Q24TotalRows
BEGIN
-- Insert into tblRESPONSE and tblSURVEY_QUESTION_RESPONSE,
-- string_split items will be trimmed first to eliminate starting and trailing spaces like (,)' Undergrad research ' to facilitate future reports
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName)
VALUES (@ProfilePK, @ResponseDateTime, (SELECT TRIM(Item) FROM #TempQ24Placeholder WHERE ItemID = @Q24CurRowNum))
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID) VALUES
((SELECT SurveyQuestionID FROM tblSURVEY_QUESTION WHERE SurveyID = @SurveyID AND QuestionID = @Question_24), SCOPE_IDENTITY())
--PRINT('QUESTION 24')
SET @Q24CurRowNum = @Q24CurRowNum + 1
END
-- Drop the temp table as always
DROP TABLE #TempQ24Placeholder
--Insert questions 22,23, and 25-27 into tblRESPONSE and tblSURVEY_RESPONSE
--Store user responses into variables
DECLARE @Response_22 varchar(30) = (SELECT Question_22 FROM WK_1 WHERE ResponseID = @RowNum);
DECLARE @Response_23 varchar(30) = (SELECT Question_23 FROM WK_1 WHERE ResponseID = @RowNum);
DECLARE @Response_25 varchar(30) = (SELECT Question_25 FROM WK_1 WHERE ResponseID = @RowNum);
DECLARE @Response_26 varchar(30) = (SELECT Question_26 FROM WK_1 WHERE ResponseID = @RowNum);
DECLARE @Response_27 varchar(30) = (SELECT Question_27 FROM WK_1 WHERE ResponseID = @RowNum);
--store QuestionID's into variables
DECLARE @Question_22 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'I am... (major status)');
DECLARE @Question_23 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'My major is...');
DECLARE @Question_25 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'Rate your level of agreement with the following statements: [I have a hard time finding my passion and my desired major.]');
DECLARE @Question_26 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'Rate your level of agreement with the following statements: [I have a hard time getting an internship.]');
DECLARE @Question_27 INT = (SELECT QuestionID FROM tblQUESTION WHERE QuestionName = 'Rate your level of agreement with the following statements: [I have a hard time connecting with people within the industry.]');
--store SurveyQuestionID's into variables
DECLARE @SurveyQuestionID_22 INT = (SELECT SurveyQuestionID FROM tblSURVEY_QUESTION WHERE SurveyID = @SurveyID AND QuestionID = @Question_22);
DECLARE @SurveyQuestionID_23 INT = (SELECT SurveyQuestionID FROM tblSURVEY_QUESTION WHERE SurveyID = @SurveyID AND QuestionID = @Question_23);
DECLARE @SurveyQuestionID_25 INT = (SELECT SurveyQuestionID FROM tblSURVEY_QUESTION WHERE SurveyID = @SurveyID AND QuestionID = @Question_25);
DECLARE @SurveyQuestionID_26 INT = (SELECT SurveyQuestionID FROM tblSURVEY_QUESTION WHERE SurveyID = @SurveyID AND QuestionID = @Question_26);
DECLARE @SurveyQuestionID_27 INT = (SELECT SurveyQuestionID FROM tblSURVEY_QUESTION WHERE SurveyID = @SurveyID AND QuestionID = @Question_27);
--insert user responses into tblRESPONSE
INSERT INTO tblRESPONSE(ProfileID, ResponseDateTime, ResponseName) --Insert into tblRESPONSE
VALUES (@ProfilePK, @ResponseDateTime, @Response_22);
DECLARE @ResponseID INT = IDENT_CURRENT('tblRESPONSE'); --Store new responseID
INSERT INTO tblSURVEY_QUESTION_RESPONSE(SurveyQuestionID, ResponseID) --Insert into tblSURVEY_QUESTION_RESPONSE
VALUES(@SurveyQuestionID_22, @ResponseID);
--PRINT('QUESTION 22')