Convert STRING to GUID
Is this possible?i've got a flat file i'm trying to import but i keep getting a "potential loss of data" error.I've tried the 'import data...' option through SSMS but no go. I've then tried making my own ssis package but it doesn't work whether i use a data conversion task or a cast in a derived column taski've tried dumping the file into a staging table with every field as varchar and I can do a select convert(uniqueidentifier,field) from staging_table just fine, so i know the data in the flat file is good.Any tips?
October 23rd, 2009 9:26am

If its a valid GUID you can convert it in a derived column like this: (DT_GUID) ("{" + YourGuid + "}")
Free Windows Admin Tool Kit Click here and download it now
October 23rd, 2009 11:24am

Can you sharethe flatfile? Is it a text file, right?
October 23rd, 2009 11:34am

If its a valid GUID you can convert it in a derived column like this: (DT_GUID) "{" + YourGuid + "}" Didn't work...Error at Data Flow Task [Derived Column [87]]: Error code 0x800401F3 occurred attempting to convert from data type DT_WSTR to data type DT_GUID. Error at Data Flow Task [Derived Column [87]]: Casting expression ""{"" from data type "DT_WSTR" to data type "DT_GUID" failed with error code 0xC00470C2. Error at Data Flow Task [Derived Column [87]]: Computing the expression "(DT_GUID) "{"+my_guid+"}"" failed with error code 0xC00470C4. The expression may have errors, such as divide by zero, that cannot be detected at parse time, or there may be an out-of-memory error. Error at Data Flow Task [Derived Column [87]]: The expression "(DT_GUID) "{"+my_guid+"}"" on "output column "Derived Column 1" (95)" is not valid. Error at Data Flow Task [Derived Column [87]]: Failed to set property "Expression" on "output column "Derived Column 1" (95)". BUT just doing "{"+my_guid+"}" then setting thedata typedrop down to dt_guid did work. As did (DT_GUID) ("{" + YourGuid + "}")Cheers!Seems kind of counterproductive for this typecast (str->guid) to not be build in in the generic 'import data...' option in SSMS. What's the 'suggest a feature' url for sql server again?
Free Windows Admin Tool Kit Click here and download it now
October 26th, 2009 1:53am

https://connect.microsoft.com/SQLServer
October 26th, 2009 4:05am

Hi Jackubk, I have an execute sql task which will retrieve thousands of guid's, for this i had taken resultset type as full result set. when creating variable there is no guid data type to assign so I had taken string and tried to load all the values into that variable I'm getting the same errors as you got. Error at Data Flow Task [Derived Column [87]]: Error code 0x800401F3 occurred attempting to convert from data type DT_WSTR to data type DT_GUID. what exactly did you do to achecive your task. Please let me know. Thanks for your help.
Free Windows Admin Tool Kit Click here and download it now
July 28th, 2011 11:22am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics