How to generate and manually insert a uniqueidentifier in sql server?

后端 未结 2 1288
南旧
南旧 2021-02-05 02:51

I\'m trying to manually create a new user in my table but impossible to generate a \"UniqueIdentifier\" type without threw an exception ...

Here is my example:



        
2条回答
  •  情话喂你
    2021-02-05 03:11

    ApplicationId must be of type UniqueIdentifier. Your code works fine if you do:

    DECLARE @TTEST TABLE
    (
      TEST UNIQUEIDENTIFIER
    )
    
    DECLARE @UNIQUEX UNIQUEIDENTIFIER
    SET @UNIQUEX = NEWID();
    
    INSERT INTO @TTEST
    (TEST)
    VALUES
    (@UNIQUEX);
    
    SELECT * FROM @TTEST
    

    Therefore I would say it is safe to assume that ApplicationId is not the correct data type.

提交回复
热议问题