You are viewing limited content. For full access, please sign in.

Question

Question

Data Insert Conversion

asked on September 16, 2015

I am trying to in rows on the trustee_attr table. To do this, I need to insert values the sid, atrr_name, and attr_val. I used a SQL Query to pull the sid from the trustee table. I am trying to insert that sid for the new row on the trustee_attr table. The error I receive is a conversion data type error. Is there way to resolve this problem or a better method?

0 0

Answer

SELECTED ANSWER
replied on September 17, 2015

How about just looking it up on the fly so SQL deals with it and you don't have to worry about conversion (which would also get rid of the "SQL Lookup SID" activity, so you'd only be making one connection and call to SQL)?

insert into trustee_attr(sid,attr_name,attr_val)
  select sid, @attr_name,@attr_val from trustee where trustee_name = @trustee_name

 

3 0
replied on September 18, 2015

Miruna,

That worked great! I finished out the workflow and every part tested out good. Thank you for all the help. If anyone is interested in seeing the final workflow design, I have included it below.

0 0

Replies

replied on September 17, 2015

You'll want to use a custom query instead of an insert so you can add in the convert language.

insert into #test    

SELECT 1, 2, convert(varbinary, 'abcdefg')

https://social.msdn.microsoft.com/forums/sqlserver/en-US/a4bd3d71-ba1c-43f5-80e3-6022111cc418/convert-string-to-varbinary

 

 

Are you doing an automated user setup with workflow instead of the SDK?

 

 

0 0
replied on September 17, 2015

I am trying to get syntax right Carl, but can't quite get it. Could you give me some more input how I may be able to write this correctly? The insert statement is working, but the sid saved to the database is not correct.

As for the automated user set up, yes that is what we are doing. We have a this data saved on an entry on a Laserfiche 8 server. I would like to move the metadata stored for each user from the template to attributes for the user automatically rather than copy and pasting manually. We have over 500 users we are moving to our Laserfiche 9 server. A SDK may be a better solution, but we do not have the in-house programmer to help us write a SDK. I am attempting to use workflow to help me complete the objective using token values from the template fields an write the data to the trustee_attr table for each user automatically.

0 0
replied on September 17, 2015 Show version history

The SID will look very different after being converted to binary.

For example, the following SID:

S-1-9-12246189-2735211543-1164372590-762507419-3091310785-6

Will become:

0x0106000000000009ADDCBA00170408A36EEA66459BF0722DC1A841B806000000

It could be the case that you're initially getting the SID back in binary, but it's being cast to a string directly, so that you're converting a string that's already in binary into binary, which would result in an incorrect SID.

replied on September 17, 2015

What do the values you have look like?  If it's the string format for a SID (like "S-1-5-20"), you can't just cast it.  You need to call a conversion function like this.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.