I need to write stored procedure that gets string. Each char in string have to be converted to int type and the converted type have to be inserted to the table.
I need to write stored procedure that gets string. Each char in string have
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The numbers table solution I posted over on this question will be your most efficient solution. Print bullet before each sentence + new line after each sentence SQL will patch code in once I’m home
Edit
The base unit of work is the inline table-valued function. You might have heard about TVF and how they suck in SQL Server but that relates to the multi-statement types. Inlines are fine as the optimizer can make sense of them and not make terrible plans.
dbo.StringSplitreturns a single column (varchar) table with the values split based on the supplied delimiter. You can cut down the lines of code required (derived tables L0 to L5) if you already have numbers table or a fast number generator in your data. I assume you don’t. The technique of using a numbers table to split data is not mine but I trust the SQL luminaries who have done the analysis.You asked for a proc so I have supplied
dbo.StringSplitToIntsto comply but all it’s doing is calling the TVF with the proper parameters. You can extract the select statement and cast into inline code or wherever you need it.