Using DECLARE Function in SQL Editor

In Kuika SQL Editor, you can define variables with the DECLARE command.

General DECLARE Format

DECLARE @variable_name data_type;

It's here,

  • @variable_name: Variable name,
  • data_type: SQL data type (e.g. nvarchar, int, bit).

Example Uses

1. Variable Definition and Data Assignment

DECLARE @top1Product nvarchar(256);SELECT TOP 1 @top1Product = productName FROM table_name;

2. Row Count Calculation

DECLARE @rowCount int;SET @rowCount = (SELECT COUNT(Id) FROM table_name);

Using DECLARE with Artificial Intelligence

  1. Press the Generate with AI button.
  2. Enter a command to create the DECLARE function that suits your needs.

Example Command:Create a DECLARE command that lists only active departments.”