Dynamics CRM‎ > ‎

SQL to insert a new account into CRM

NOTE:   Microsoft doesn't officially support people inserting records into Microsoft CRM using SQL.   Microsoft CRM has a web service that you can use to insert records into it, which is the official method of inserting records into CRM.  So if you choose to use this code, do so at your own risk.
--Code begins
Declare @GUID as uniqueidentifier
Declare @AddressGUID as uniqueidentifier
Set @AddressGUID=NEWID()
insert into Test_MSCRM.dbo.AccountBase (AccountId, Name, statecode, ownerid, OwningBusinessUnit, CreatedBy, createdon, ModifiedOn, ModifiedBy, TransactionCurrencyId)
values (@GUID, 'ICB Consulting, Inc.',0,'7C0EAC14-0284-E111-942D-00155D017404','20BA18D3-F383-E111-A325-00155D017404','7C0EAC14-0284-E111-942D-00155D017404', GETDATE(),
GETDATE(), '7C0EAC14-0284-E111-942D-00155D017404', '6E00433B-F483-E111-A325-00155D017404'
insert into Test_MSCRM.dbo.AccountExtensionBase (AccountId, new_CIFNumber) values (@GUID, '9999999')
insert into Test_MSCRM.dbo.CustomerAddressBase (ParentId, CustomerAddressId, AddressNumber, objecttypecode, Line3, City, StateOrProvince, PostalCode, CreatedBy, CreatedOn, ModifiedBy, ModifiedOn)
values (@GUID, @AddressGUID,'1', '1', '1400 Simms, Suite 240', 'Lakewood', 'CO', '80401',
'7C0EAC14-0284-E111-942D-00155D017404', GETDATE(), '7C0EAC14-0284-E111-942D-00155D017404', GETDATE())