Here I'm trying to write a function for extracting each digit from a number and return a table with column UserId and Number. But i'm getting syntax error. Logic is working i'm just unable to arrange things in proper manner. If i pass userid as akshay and number as 1234 so this function must return a table as akshay 1 akshay 2 akshay 3 akshay 4
Asked
Active
Viewed 70 times
-4
-
3Add code and errormessages as text not as link to an image – Jens Feb 02 '18 at 06:42
-
`(MS)SQL-Server` is not `mysql`. Please remove unrelated tags – Jens Feb 02 '18 at 06:43
-
by != do you mean <>? – sanatsathyan Feb 02 '18 at 06:48
1 Answers
1
You should define variable for the return table
RETURNS @returnTable TABLE
(
UserId varchar(20),
ModNumber smallint
)
Please check this reference : tsql returning a table from a function or store procedure

Ramesh Rajendran
- 37,412
- 45
- 153
- 234
-
Ramesh thankyou but now m getting error on Create Function Line "Incorrect Syntax: Create Function must be the only statement in the batch" – akshay sahu Feb 02 '18 at 07:17
-
-
Please don't ask question before search in google: https://www.google.co.in/search?dcr=0&source=hp&ei=shB0WtCYL4q6vwTNpLnYDA&q=Create+Function+must+be+the+only+statement+in+the+batch&oq=Create+Function+must+be+the+only+statement+in+the+batch&gs_l=psy-ab.3..0j0i22i30k1.654.654.0.2226.2.1.0.0.0.0.214.214.2-1.1.0....0...1c.1.64.psy-ab..1.1.213.0...0.UjD3KUXSfmU – Ramesh Rajendran Feb 02 '18 at 07:20