CREATE TABLE Survey (
survey_nbr INT NOT NULL PRIMARY KEY,
survey_desc VARCHAR(30),
survey_info1 VARCHAR(30) SPARSE NULL,
survey_info2 VARCHAR(30) SPARSE NULL,
survey_info3 VARCHAR(30) SPARSE NULL,
survey_info4 VARCHAR(30) SPARSE NULL);
INSERT INTO Survey(survey_nbr, survey_desc, survey_info1)
VALUES(1, 'Survey 1', 'some data'),
(2, 'Survey 2', 'good');
CREATE TABLE Survey (
survey_nbr INT NOT NULL PRIMARY KEY,
survey_desc VARCHAR(30),
survey_info1 VARCHAR(30) SPARSE NULL,
survey_info2 VARCHAR(30) SPARSE NULL,
survey_info3 VARCHAR(30) SPARSE NULL,
survey_info4 VARCHAR(30) SPARSE NULL,
survey_set XML column_set FOR ALL_SPARSE_COLUMNS);
-- Insert using the regular sparse columns
INSERT INTO Survey(survey_nbr, survey_desc, survey_info1)
VALUES(1, 'Survey 1', 'some data'),
(2, 'Survey 2', 'good');
-- Insert using the column set
INSERT INTO Survey(survey_nbr, survey_desc, survey_set)
VALUES(3, 'Survey 3', '<survey_info3>data 3</survey_info3><survey_info4>answer 4</survey_info4>');
Labels: sql server 2008, t-sql programming