How to query two database

Hello guys Please I have this script VTable and AccTable are on separate database. Please anyone help with a sample workflow to execute this query in the studio

update VTable
set ACCOUNT_NUMBER = (select Distinct ACCOUNT_NUMBER from AccTable where VTable.FULL_PAN = AccTable.PAN)

Best Regards

@MasterOfLogic

Install UiPath.Databases.activities package

Use Connect activity to successful connection to your database

Now use Execute Query activity to write your script

Else you can also create store procedure and select the store procedure from the properties

Hope this may help you

Thanks

	Using fcon As New System.data.SqlClient.SqlConnection("Data Source="+dataSource+";Initial Catalog="+initialCatalogue+";User ID="+userName+";Password="+password)
		fcon.Open()
		
			Using cmd As New System.Data.SqlClient.SqlCommand  'Create command object
				cmd.CommandType = CommandType.Text 'Set the commandType
				cmd.Connection = fcon  'Set the connection object that will be used
				cmd.CommandText = "" ' query 
	End Using

hello @Srini84 thank you I am already aware of some of the things you noted , I use an invoke code to run my query just as seen above but the broblem i am having is that this type the query involves two tables from different data base

@MasterOfLogic

If you have the activities which are ready, then why to use of Invoke code writing this code?

Can you try as using the activities, that makes life easier

Thanks

@Srini84 , okay please where do i find the ‘select the store procedure from the properties’ on the execute query activity

Hi @MasterOfLogic ,

if you want to execute stored procedure you have to use execute non query activity and select the command type as stored procedure and give your stored procedure name in the Sql field. please refer the below thread for more guidance. thanks.

2 Likes

@MasterOfLogic

Check below for your reference

image

Thanks

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.