Passing parameter of type 'object' in table-valued parameter for sql_variant column

前端 未结 3 1910
遥遥无期
遥遥无期 2021-01-08 00:29

I have a table-valued parameter in SQL Server 2012 defined as:

CREATE TYPE [dbo].[TVP] AS TABLE (
    [Id] [int] NOT NULL,
    [FieldName] [nvarchar](100) NO         


        
3条回答
  •  心在旅途
    2021-01-08 00:54

    Unfortunately, I don't have time right now to completely answer this, but I can get you on the right path.

    What I have done in the past is, rather than using a TVP, use an XML parameter, serialize the dataset (or any POCO, for that matter)as XML, pass that XML into the proc, then use the ".nodes" property (and other members) of the xml variable to extract whatever was needed into temp tables, local table vars, "work tables" etc...

    That's vague, but if you serialize that dataset, and inspect the xml that's created, and read up on XML Data Types in Books On Line, you will likely be able to figure out how to complete your task.

    If that doesn't help, I will try to put together an actual solution tomorrow, as I just came across this question as I was leaving for the day.

    Cheers!!

提交回复
热议问题