This expandable item provides the following options that allow you to specify the attributes with which you want to uniquely identify each object in the connected data system:
- Available attributes. Lists the attributes that are available in the external data system. Use this list to select the attributes whose values you want to use to generate a unique identifier for each object in the external data system. You can filter attributes by typing in the text box at the top of this list. To select multiple attributes, hold down CTRL and click to select attributes in the list.
- UniqueID attributes. Lists the attributes whose values are currently used to generate a unique identifier for each object in the external data system.
- Add->. Moves the selected attributes from the Available attributes list to the UniqueID attributes list.
- <-Remove. Moves the selected attributes from the UniqueID attributes list to the Available attributes list.
- Constructed UniqueID. Displays a combination of the attributes whose values will make up a unique identifier for each object in the external data system.
This section provides some sample SQL queries illustrating how to modify SQL Server data during synchronization operations. In the sample queries, Id refers to an attribute (a column name in an SQL Server table) that uniquely identifies an object in your SQL database. These examples can be used only for configuring connections to Microsoft SQL Server 2005.
This sample illustrates how to create a query that inserts an object with specified attributes into the table named SQLConnTest1.
Table 56: How to insert an object into a table
CREATE TABLE [SQLConnTest1]([Id] [bigint] IDENTITY(1,1),[attr1] [nchar](64),[attr2] [nchar](64)))
INSERT into SQLConnTest1(Id) values(@Id)
This sample illustrates how to create a SQL Server account, and then retrieve the UniqueID attribute for that account.
To define the scope where to create the SQL Server account, insert the following query in the Query Editor dialog box:
SELECT sid as Id,name as login from sys.server_principals
Insert the following SQL query into the Configure SQL Statements dialog box:
EXEC sp_addlogin @login, @newPassword;
EXEC sp_adduser @login,@login,'db_owner';
SELECT sid as Id from sys.server_principals where name=@login;
IMPORTANT: None of attribute names used in SQL queries can include white-space characters. For example, you cannot use names such as "user password".