hi I have a issue with the like operator in the loop if I set the like operator to LIKE '[@a-b]%'when execute the SP with the parameter @a = a I got this in my wanado table[b]ContactName[/b]Antonio del Valle SaavedraAnne HeikkonenBeate Vileidif I set the like operator to LIKE '[@a-@b]%'when execute the SP with the parameters @a = a and @b = b I got this in my wanado table[b]ContactName[/b]Beate VileidSo what do I wrong ? in the code ??USE [Northwind]GO/****** Object: StoredProcedure [dbo].[SupplierStats] Script Date: 22-08-2016 18:01:15 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER PROC [dbo].[SupplierStats] -- ALTER PROC SupplierStats @a nvarchar(50), @b nvarchar(50)AS BEGIN DECLARE @imax INT, @i INT DECLARE @Contact VARCHAR(100), @Company VARCHAR(50) DECLARE @CompanyInfo TABLE( RowID INT IDENTITY ( 1 , 1 ), CompanyName VARCHAR(100), ContactName VARCHAR(50) ) INSERT @CompanyInfo SELECT CompanyName, ContactName FROM Suppliers WHERE ContactName LIKE '[@a-@b]%' ORDER BY CompanyName SET @imax = @@ROWCOUNT SET @i = 1 WHILE (@i <= @imax) BEGIN SELECT @Contact = ContactName, @Company = CompanyName FROM @CompanyInfo WHERE RowID = @i ------------------------------------------------------ -- INSERT PROCESSING HERE INSERT INTO dbo.wanado (ContactName, CompanyName)VALUES (@Contact, @Company); ------------------------------------------------------ PRINT CONVERT(varchar,@i)+' Contact: ' + @Contact + ' at ' + @Company SET @i = @i + 1 END -- WHILE END -- SPROC
↧