vamsi k

vamsi k

  • 1.6k
  • 110
  • 1.7k

User defined table type in SQL Server

Oct 4 2022 10:26 AM

Hi All,

Need your help in User-defined table type.
In oracle we have a user-defined table type
create or replace TYPE "names" as TABLE OF VARCHAR(50)
In the table we have a column ACTNAMES and when we execute that table result is like below
SELECT * FROM Organization
Output:
ACTNAMES
names('SSM - Respond to Surveys is Good','SSM - View All Response is Good') -- This is properly fit with the user-defined table type in oracle
How can we do the same thing in sql server with user-defined table type?
I have created a sample table
CREATE TABLE Test(ACTIVITY_NAMES VARCHAR(50))
I have created user-defined table type
CREATE TYPE ACTIVITY_NAMES_NT AS TABLE ( ACTIVITY_NAMES VARCHAR(50) )
I want data should be saved in the column ACTIVITY_NAMES like this 'SSM - Respond to Surveys is Good' ,'SSM - View All Response is Good'
Note: This complete ['SSM - Respond to Surveys is Good' ,'SSM - View All Response is Good'] value must be in single column and it must be fit with VARCHAR(50)

 

Please assist us with an example


Answers (1)