Create a product
Creates a new product record in the Products table. This example demonstrates how to use the INSERT INTO statement to specify product details such as name, description, dimensions, and images.
Standard SQL query example
This is the base query accepted by the connector. To execute it in SQL Server, you have to pass it to the Data Gateway via a Linked Server. See how to accomplish this using the examples below.
INSERT INTO Products
( [Name]
, [Caption]
, [Description]
, [Type]
--, [UnitLabel] --only when product type=service
, [Active]
, [PackageDimensionsHeight]
, [PackageDimensionsWidth]
, [PackageDimensionsLength]
, [PackageDimensionsWeight]
, [URL]
, [Image1]
, [Image2]
, [Image3]
)
VALUES('SSIS PowerPack 3'
, 'SSIS Caption 3'
, 'SSIS PowerPack description long ....'
, 'good' --or service
--, 'Unit label' --only when product type=service
, 'True' --active ?
, '12'
, '13'
, '14'
, '1000'
, 'https://zappysys.com/products/ssis-powerpack/'
, 'https://zappysys.com/images/tech/web-api-logo.png'
, 'https://zappysys.com/images/tech/xml-logo.png'
, 'https://zappysys.com/images/tech/salesforce-logo.png'
)
Using OPENQUERY in SQL Server
SELECT * FROM OPENQUERY([LS_TO_STRIPE_IN_GATEWAY], 'INSERT INTO Products
( [Name]
, [Caption]
, [Description]
, [Type]
--, [UnitLabel] --only when product type=service
, [Active]
, [PackageDimensionsHeight]
, [PackageDimensionsWidth]
, [PackageDimensionsLength]
, [PackageDimensionsWeight]
, [URL]
, [Image1]
, [Image2]
, [Image3]
)
VALUES(''SSIS PowerPack 3''
, ''SSIS Caption 3''
, ''SSIS PowerPack description long ....''
, ''good'' --or service
--, ''Unit label'' --only when product type=service
, ''True'' --active ?
, ''12''
, ''13''
, ''14''
, ''1000''
, ''https://zappysys.com/products/ssis-powerpack/''
, ''https://zappysys.com/images/tech/web-api-logo.png''
, ''https://zappysys.com/images/tech/xml-logo.png''
, ''https://zappysys.com/images/tech/salesforce-logo.png''
)')
Using EXEC in SQL Server (handling larger SQL text)
The major drawback of OPENQUERY is its inability to incorporate variables within SQL statements.
This often leads to the use of cumbersome dynamic SQL (with numerous ticks and escape characters).
Fortunately, starting with SQL 2005 and onwards, you can utilize the EXEC (your_sql) AT [LS_TO_STRIPE_IN_GATEWAY] syntax.
DECLARE @MyQuery NVARCHAR(MAX) = 'INSERT INTO Products
( [Name]
, [Caption]
, [Description]
, [Type]
--, [UnitLabel] --only when product type=service
, [Active]
, [PackageDimensionsHeight]
, [PackageDimensionsWidth]
, [PackageDimensionsLength]
, [PackageDimensionsWeight]
, [URL]
, [Image1]
, [Image2]
, [Image3]
)
VALUES(''SSIS PowerPack 3''
, ''SSIS Caption 3''
, ''SSIS PowerPack description long ....''
, ''good'' --or service
--, ''Unit label'' --only when product type=service
, ''True'' --active ?
, ''12''
, ''13''
, ''14''
, ''1000''
, ''https://zappysys.com/products/ssis-powerpack/''
, ''https://zappysys.com/images/tech/web-api-logo.png''
, ''https://zappysys.com/images/tech/xml-logo.png''
, ''https://zappysys.com/images/tech/salesforce-logo.png''
)'
EXEC (@MyQuery) AT [LS_TO_STRIPE_IN_GATEWAY]