Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE PROCEDURE PrintCustomers_Cursor AS BEGIN SET NOCOUNT ON; DECLARE @CustomerId INT ,@Name VARCHAR(100) ,@Country VARCHAR(100) DECLARE Counter

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE PROCEDURE PrintCustomers_Cursor

AS

BEGIN

SET NOCOUNT ON;

DECLARE @CustomerId INT

,@Name VARCHAR(100)

,@Country VARCHAR(100)

DECLARE Counter DATE

SET Counter = 1

DECLARE PrintCustomers READ_ONLY

FOR

SELECT CustomerId, Name, Country

FROM Customers

OPEN PrintCustomers

FETCH FROM PrintCustomers INTO

@CustomerId, @Name, @Country

WHILE @@FETCH_STATUS = 0

BEGIN

IF @Counter = 1

BEGIN

PRINT 'CustomerID' + CHAR(9) + 'Name' + CHAR(9) + CHAR(9) + CHAR(9) + 'Country'

PRINT '------------------------------------'

END

PRINT (@CustomerId AS VARCHAR(10)) + CHAR(9) + CHAR(9) + CHAR(9) + @Name + CHAR(9) + @Country

SET Counter = Counter + 1

FETCH FROM PrintCustomers INTO

@CustomerId, @Name, @Country

END

DEALLOCATE PrintCustomers

CLOSE PrintCustomers

END

GO

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Reliability Engineering Designing And Operating Resilient Database Systems

Authors: Laine Campbell, Charity Majors

1st Edition

978-1491925942

More Books

Students also viewed these Databases questions

Question

Find the value of the sum.

Answered: 1 week ago

Question

=+Are you interested in working on global teams?

Answered: 1 week ago

Question

=+Do you want to work from home?

Answered: 1 week ago

Question

=+ What skills and competencies will enable someone

Answered: 1 week ago