Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
cwfontan
Yak Posting Veteran
87 Posts |
Posted - 2009-06-11 : 16:29:41
|
in a nutshell i want to pass a param to my SP and have the matchtext function strip it then the matchtext fn selects some table data to compare to.. i want to use the comparetext fn to compare the single value param1 to all the values returned by the select dbo.tblLanxLocsSET @@param1 = 'textstringinfo' --going to pass param1 in from appSET @@param2 --i have a function i use to select these records --it removes all nonalphacharacters and all sound letters--do I use a cursor? SELECT [QDINC\UserName].[MatchText](locName + '' + City) FROM dbo.tblLanxLocs--how can i get the result of this into a variable?--or can I just use it as a subselect since only 1 result? SELECT [QDINC\USERNAME].[MatchText](@@param1)--one more function that takes the param1 and compares it to param2--i need to iterate through the results of the first Select??cursor?--something like this? fetch next from myCursor into @@param2 SELECT [QDINC\UserName].[CompareText](@@param1, @@param2) I need help making this sproc |
|
|
cwfontan
Yak Posting Veteran
87 Posts |
Posted - 2009-06-11 : 18:27:20
|
| This is what I came up with so far.. it does compare but seems like compares with only 1 record.. can anyone see what I have wrong and why the function would not compare to each row?USE [GP_DB]GO/****** Object: StoredProcedure [dbo].[sp_Test] Script Date: 06/11/2009 16:37:11 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER PROCEDURE [dbo].[sp_Test]@@param1 nvarchar(max)as SET NOCOUNT ON--DECLARE @colA nvarchar(10) --DECLARE @colB nvarchar(10) DECLARE @MyCursor CURSOR --Declare @@param1 nvarchar(max)Declare @@param2 nvarchar(max)SET @@param1 = 'CMMRCLWHSCMPNYLBQRQ'--(SELECT [QDINC\user].[MatchText](@@param1))SET @MyCursor = CURSOR FAST_FORWARD FOR SELECT [QDINC\user].[MatchText](locName + '' + City) FROM dbo.tblLanxLocsOPEN @MyCursor FETCH NEXT FROM @MyCursor INTO @@param2WHILE @@FETCH_STATUS = 0BEGIN SELECT [QDINC\user].[CompareText](@@param1, @@param2)FETCH NEXT FROM @MyCursorEND CLOSE @MyCursor DEALLOCATE @MyCursor |
 |
|
|
cwfontan
Yak Posting Veteran
87 Posts |
Posted - 2009-06-12 : 09:30:57
|
| I resolved my issueUSE [GP_Custom]GO/****** Object: StoredProcedure [dbo].[sp_Test] Script Date: 06/12/2009 07:35:29 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER PROCEDURE [dbo].[sp_Test]@@param1 nvarchar(max)as SET NOCOUNT ON--DECLARE @colA nvarchar(10) --DECLARE @colB nvarchar(10) Declare @@param2 nvarchar(max)Declare @@counter intSet @@counter = 0SET @@param1 = 'CMMRCLWHSCMPNYLBQRQ'--(SELECT [QDINC\user].[MatchText](@@param1))--Declare @@param1 nvarchar(max)DECLARE MyCursor CURSOR FAST_FORWARDFOR SELECT [QDINC\user].[MatchText](locName + '' + City) FROM dbo.tblLanxLocsOPEN MyCursor FETCH NEXT FROM MyCursor INTO @@param2WHILE @@FETCH_STATUS = 0BEGIN FETCH NEXT FROM MyCursorINTO @@param2SELECT [QDINC\user].[CompareText](@@param1, @@param2) set @@counter=@@counter+1END CLOSE MyCursor DEALLOCATE MyCursor |
 |
|
|
|
|
|