Using DECLARE Function in SQL Editor

You can declare variables using the DECLARE statement in the Kuika SQL Editor.

General DECLARE Format

DECLARE @variable_name data_type;

Here:

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

Example Usages

1. Defining a Variable and Assigning Data

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

2. Calculating the Number of Rows

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

Using DECLARE with Kuika AI

  1. Open the Kuika AI tab in the right panel.
  2. Type a command to create a DECLARE statement that suits your needs.

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