mercredi 30 décembre 2015

I want to include an If statement in my SQL script

I have this insert statement I wrote, but I want to test for null before I insert data into the database> Below is the code

use master
DECLARE @PriviledgeID uniqueidentifier
DECLARE @UserName uniqueidentifier 

SELECT @PriviledgeID=roleId 
FROM aspnet_Roles 
WHERE RoleName = 'Operator'

SELECT @UserName=USERID
FROM aspnet_Users
WHERE username = ments@point.com'


INSERT INTO aspnet_UsersInRoles
 VALUES(@UserName, @PriviledgeID )

My aim is to make sure I don't insert values of null into the database, how can I do this? Thanks.

Aucun commentaire:

Enregistrer un commentaire