Hi Everyone
I have 2 tables, one contains client admissions and the other client discharges, both tables have a lot of columns. This is an old system that has been refined over time and the problem I'm working on requires to create a discharge for every client that has had no services in a certain amount of time. For this I'm planning on doing:
1.- Create Cursor to select clients with no services in amount of time (and no discharge).
2.- For each row in cursor
2.1 Generate discharge
2.2 Get the @@Identity
2.2 Link admission with the newly created discharge (@@Identity)
Both tables have close to 200 columns and are basically the same information (like mental health status at admission and mental health status at discharge), so basically I'm "copying" the data in admission to generate the discharge.
When I worked in Informix I remember there was a way to declare a record variable that would contain all the columns of the table:
Define VARIABLE LIKE TABLE.*
So basically you don't have to declare every single column as a separate variable and the fetch would go like:
Fetch INTO VARIABLE.*
Instead of
Fetch INTO Col1,Col2,.....ColN
I've been searching for a while and I can't seem to find something similar in TSQL. Do I really have to declare 200 variables for the fetch or is there something like the declare in Informix?
Thanks in advance for your help
Luis Torres
I have 2 tables, one contains client admissions and the other client discharges, both tables have a lot of columns. This is an old system that has been refined over time and the problem I'm working on requires to create a discharge for every client that has had no services in a certain amount of time. For this I'm planning on doing:
1.- Create Cursor to select clients with no services in amount of time (and no discharge).
2.- For each row in cursor
2.1 Generate discharge
2.2 Get the @@Identity
2.2 Link admission with the newly created discharge (@@Identity)
Both tables have close to 200 columns and are basically the same information (like mental health status at admission and mental health status at discharge), so basically I'm "copying" the data in admission to generate the discharge.
When I worked in Informix I remember there was a way to declare a record variable that would contain all the columns of the table:
Define VARIABLE LIKE TABLE.*
So basically you don't have to declare every single column as a separate variable and the fetch would go like:
Fetch INTO VARIABLE.*
Instead of
Fetch INTO Col1,Col2,.....ColN
I've been searching for a while and I can't seem to find something similar in TSQL. Do I really have to declare 200 variables for the fetch or is there something like the declare in Informix?
Thanks in advance for your help
Luis Torres