PDA

View Full Version : insert into



ly.comeng
دوشنبه 15 فروردین 1390, 10:58 صبح
با سلام
من 3 تا جدوا دارم
groups
permission
grouppermission
که می خوام برای groupid=100 همه permissionid ها رو در جدول grouppermission
insert کنم
یه همچین چیزی نوشتم:

use Hot;

insert into GroupPermissions

(PermissionID)

select PermissionID from Permissions inner join GroupPermissions on PermissionID=Permissions.ID
where GroupPermissions.GroupID=100


این هم Error اش:

Msg 515, Level 16, State 2, Line 2
Cannot insert the value NULL into column 'GroupID', table 'Hot.dbo.GroupPermissions'; column does not allow nulls. INSERT fails.
The statement has been terminated.


لطفا راهنمایی کنید

محمد سلیم آبادی
دوشنبه 15 فروردین 1390, 11:56 صبح
INSERT INTO GroupPermission (GroupID, permissionID)
SELECT groupid, permissionid
FROM Groups CROSS JOIN Permission
WHERE groupid = 100;