我有問題,我的代碼:消息512 ... SQL Server代碼
drop type Pesel
go
drop assembly pesel
go
create assembly pesel
authorization dbo from 'C:\Users\Logan\Desktop\Projekt\Projekt.dll' with permission_set = safe
go
create type dbo.Pesel
external name Pesel.Pesel
go
declare @a Pesel
select * from dbo.dane
set @a = (select numer_pesel as pesel from dbo.dane)
select @a.ValidatePesel()
select @a.BirthDate()
select @a.GetGender()
我得到了一個錯誤:
Msg 512, Level 16, State 1, Line 15
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
當我嘗試它,例如像這樣:
set @a = cast('93071611479' as pesel)
一切正常,但它仍然只有1個答案:P
編輯:
我已經成功地至少部分地解決我的問題,但現在我希望把我的成果轉化爲表
drop type Pesel
go
drop assembly pesel
go
create assembly pesel
authorization dbo
from 'C:\Users\Logan\Desktop\Projekt\Projekt.dll'
with permission_set = safe
go
create type dbo.Pesel
external name Pesel.Pesel
go
declare @a Pesel
select * from dbo.dane
declare @b int
set @b = 0
while @b < (select max(P_Id) from dane)
begin
set @a = (select numer_pesel as pesel from dane where P_Id = [email protected])
set @b += 1
if (select numer_pesel from dane) = null
break
select @a.ValidatePesel()
select @a.BirthDate()
select @a.GetGender()
end
我試圖創建表,並把上述選擇成列,但不知何故,它不起作用。任何提示球員:)?
(1)我刪除了MySQL的標籤,因爲代碼顯然是T-SQL。 (2)錯誤信息非常明顯:'dane'有不止一行。有什麼你不明白的嗎? –