sql - Conversion failed converting from a character string to uniqueidentifier -


i have set of 200 unique id's revenue batch need run stored procedure against. idea create temp table, insert unique values, run stored proc against temp table , drop temp table. whenever execute code receiving error message "conversion failed when converting character string uniqueidentifier." can not figure out why getting error. familiar error possibly me out? can @ code , see reason message? appreciated. code below sample size unique id's:

create table #removal (revid uniqueidentifier, luid char (12)) insert  #removal(revid, luid)values (cast ('rev-55326898'as uniqueidentifier), '8-11838757'),(cast ('rev-55326899'as uniqueidentifier), '8-16960881') declare @field1 uniqueidentifier declare @field2 int declare cur cursor local select revid #removal open cur fetch next cur @field1 while @@fetch_status = 0 begin exec usp_revenue_delete @field1, @field2 fetch next cur @field1 end close cur deallocate cur drop table #removal 

your values (ie: rev-55326898) don't match format unique identifier in sql server.

a unique identifier in sql server 16-byte guid. there 2 ways initialize value data type (from msdn):

  • by using newid function.
  • by converting string constant in form xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, in each x hexadecimal digit in range 0-9 or a-f. example, 6f9619ff-8b86-d011-b42d-00c04fc964ff valid uniqueidentifier value.

see: https://msdn.microsoft.com/en-us/library/ms187942.aspx


Comments

Popular posts from this blog

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

html - Outlook 2010 Anchor (url/address/link) -

android - How to create dynamically Fragment pager adapter -