Database Scripts
Best practice for production apps is to use REST as the data layer to access data and not directly integrate to SQL using the SQL data provider. The SQL data provider will be squiggled in blue to indicate it is not recommended, together with a message to use REST instead. See REST endpoints from Azure SQL for more information.
The following Azure SQL scripts create the customer table and store the procedures used in the examples in this section. These scripts should be executed against an existing database in your Azure SQL environment.
Create Customer Table
The following script creates a sample customer table in Microsoft Azure SQL.
CREATE TABLE customers (
id UNIQUEIDENTIFIER PRIMARY KEY DEFAULT NEWID(),
first_name NVARCHAR(50) NOT NULL,
last_name NVARCHAR(50) NOT NULL,
email NVARCHAR(100) UNIQUE NOT NULL,
phone_number NVARCHAR(15) UNIQUE,
address_line1 NVARCHAR(100) NOT NULL,
address_line2 NVARCHAR(100),
city NVARCHAR(50) NOT NULL,
state CHAR(2) NOT NULL DEFAULT 'WA',
zip_code CHAR(5) NOT NULL,
country NVARCHAR(50) NOT NULL DEFAULT 'USA'
);Insert sample records in the Customer table
The following script inserts sample customers into the table.
Stored procedure for selecting a list of customers
The following script creates a store procedure that will return all the customers in the customer table.
Stored procedure for selecting one customer
The following script will create a store procedure to return a single customer record for the provided customer id.
Stored procedure for creating or updating a customer record
The following script creates a stored procedure that will add a new customer record if the customer id does not exist. It will update an existing customer if the id does exist.
Last updated
Was this helpful?