久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

使用來自 UDF 的結(jié)果集插入表變量

Insert into table variable using result set from a UDF(使用來自 UDF 的結(jié)果集插入表變量)
本文介紹了使用來自 UDF 的結(jié)果集插入表變量的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我有一個 UDF,它采用逗號分隔的列表并將其轉(zhuǎn)換為行所以

I have a UDF which takes a comma separated list and turns it into rows So the output of

select * from fnDrugSplit('one,two,three',',')

one
two
three

當我嘗試將這些結(jié)果插入到表變量中時

When I try to insert these results into a table variable with

declare @drugName1 table(drugName1 varchar(50),drugName2 varchar(50))
insert into @drugName1(drugName1,drugName2)
values(
         (select * from fnDrugSplit('one,two,three',',')
        ,(select * from fnDrugSplit('one,two,three',',')
      )

我發(fā)現(xiàn) ')' 附近的語法不正確,最后一個括號將 values 塊關(guān)閉.該函數(shù)將是確定性的,我不知道為什么會收到此錯誤,因為

I get Incorrect syntax near ')', the last parentheses closing out the values block. The function will is deterministic and I don't know why I'm getting this error because

declare @drugName1 table(drugName1 varchar(50),drugName2 varchar(50))
insert into @drugName1(drugName1,drugName2)
values(
         (select 'one')
        ,(select 'two')
      )
select * from @drugName1

工作正常.我在這里錯過了什么?

works fine. What am I missing here?

函數(shù)中的第二個參數(shù)是行的分隔符.SQL Server 2008

The second parameter in the function is the delimiter for rows. SQL Server 2008

推薦答案

您的 udf 返回一個包含 3 行的表.您不能使用VALUES"子句將 1 列的 3 行放入表中.VALUES"子句需要標量,這就是Select 'one'"和Select 'two'"起作用的原因.

Your udf returns a table with 3 rows. You can't put 3 rows of 1 column into the table with the "VALUES" clause. The "VALUES" clause expects scalars, which is why "Select 'one'" and "Select 'two'" work.

您不需要VALUES",您可以明確表達您的選擇.

You don't need "VALUES" you can just articulate your select.

Insert into @drugName1
(drugName1, drugName2)
 select fn.ColName, fn.ColName
 from fnDrugSplit('one,two,three',',') fn

不確定如何將 3 個值放入 2 列,這在您的問題中不清楚.另外,我不知道您的 UDF 的列名是什么,所以我假設(shè)了 ColName.

Not sure how you want to put 3 values into 2 columns, that wasn't clear in your question. Also, I don't know what the column name is for your UDF, so I assumed ColName.

這篇關(guān)于使用來自 UDF 的結(jié)果集插入表變量的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Modify Existing decimal places info(修改現(xiàn)有小數(shù)位信息)
The correlation name #39;CONVERT#39; is specified multiple times(多次指定相關(guān)名稱“CONVERT)
T-SQL left join not returning null columns(T-SQL 左連接不返回空列)
remove duplicates from comma or pipeline operator string(從逗號或管道運算符字符串中刪除重復項)
Change an iterative query to a relational set-based query(將迭代查詢更改為基于關(guān)系集的查詢)
concatenate a zero onto sql server select value shows 4 digits still and not 5(將零連接到 sql server 選擇值仍然顯示 4 位而不是 5)
主站蜘蛛池模板: 九九热在线观看 | 久久精品亚洲成在人线av网址 | 午夜欧美一区二区三区在线播放 | 伊人免费在线观看高清 | 久久人人网 | 国产成人综合在线 | 亚洲综合资源 | 国产欧美精品一区二区三区 | 国产福利精品一区 | 国产精品一区在线 | 91影院在线观看 | 91精品国产91久久综合桃花 | 狠狠干狠狠操 | 国产一级片一区二区三区 | 91最新视频| 亚洲精品一| 国产一级免费视频 | 二区成人 | 亚洲天堂av网 | 成人精品久久久 | 成人精品一区二区三区中文字幕 | 国产综合久久久 | 亚洲综合婷婷 | 日韩手机视频 | 男女下面一进一出网站 | 人人看人人搞 | 欧美久久视频 | 国产精品免费一区二区三区四区 | 天天拍天天操 | 在线播放一区二区三区 | 国产在线小视频 | 日韩中文字幕高清 | 日韩a | 91 在线| 91视频导航 | 日韩爱爱网 | 99视频在线免费观看 | 午夜影晥 | 婷婷久| 国产亚洲www| 午夜影院在线观看视频 |