Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 697079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:07:52+00:00 2026-05-14T03:07:52+00:00

I have a nvarchar(50) column in a SQL Server 2000 table defined as follows:

  • 0

I have a nvarchar(50) column in a SQL Server 2000 table defined as follows:

TaskID nvarchar(50) NULL

I need to populate this column with random SQL GUID’s using the NEWID() function (I am unable to change the column type to uniqueidentifier).

I tried this:

UPDATE TaskData SET TaskID = CAST(NEWID() AS nvarchar)

but I got the following error:

Msg 8115, Level 16, State 2, Line 1
Arithmetic overflow error converting
expression to data type nvarchar.

I also tried:

UPDATE TaskData SET TaskID = CAST(NEWID() AS nvarchar(50))

but then got this error:

Msg 8152, Level 16, State 6, Line 1
String or binary data would be
truncated.

I don’t understand why this doesn’t work but this does:

DECLARE @TaskID nvarchar(50)
SET @TaskID = CAST(NEW() AS nvarchar(50))

I also tried CONVERT(nvarchar, NEWID()) and CONVERT(nvarchar(50), NEWID()) but got the same errors.

Update:

Ok, my eyesight is going, the column size on the table is nvarchar(32) not 50. Deepest apologies for the timewasting and thanks for all the answers.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:07:52+00:00Added an answer on May 14, 2026 at 3:07 am

    This test script works fine for me… I can only suggest that maybe your TaskId isn’t an NVARCHAR(50) like you say? Try an sp_columns just to check…

    CREATE Table #TaskData (TaskId NVARCHAR(50))
    INSERT INTO #TaskData (TaskId) SELECT CONVERT(NVARCHAR(50), NEWID())
    UPDATE #TaskData SET TaskId = CONVERT(NVARCHAR(50), NEWID())
    DROP TABLE #TaskData
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a nvarchar(2000) column in a SQL Server 2005 database, and have mapped
Hey guys, I have a column in an sql server table that is nvarchar(max).
Currently I have a SQL server column of type nvarchar(max) which has text that
I have a SQL Server 2008 database. This database has a Table called Book.
I have a simple table in my SQL Server database. This table contains two
I have a column in SQL Server 2008 R2 that is NVARCHAR(MAX). I would
I have two SQL Server tables. One table has four nvarchar(50) nullable columns and
Need help with this SQL Server 2000 procedure. The problem is made difficult because
I'm using SQL Server 2008. I have a NVARCHAR(MAX) column called Title and i
I'm using SQL Server 2008. I've got a column NVARCHAR(MAX) in a table which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.