jeudi 19 juillet 2018

Printing warning statement with IF loop in SQL Server

http://www.sqlfiddle.com/#!18/9eecb/25446

DECLARE @Test int
SET @Test = '6'
IF @Test > 5 PRINT N'Warning - large queries may take time'
ELSE PRINT N'Query will run normally';
GO

I have a query where the '@Test' variable can be changed to any number. The above SQL kind of demonstrates the logic. If someone enters a number higher than 5 for example i want there to be a warning message advising the user about the larger query. Is this possible in SQL? I ran this code but it returns nothing. Am i in the right direction? thanks

Aucun commentaire:

Enregistrer un commentaire