Question : SQL Server - How to find a string inside a variable?

hi experts,

i've got 4 tables related to users in my db. i have categorized tables according to type of information. some are login details (user/password), some are contact info, and some are basic info.

i'm going to represent them on the user interface by tabs because the user may not enter all so not all table are going to be affected. but with one save button.

my question is, since i'm using stroed procedures, how to implement this inside my stored procedure? do i send an indicator parameter from my page to the stored procedure to tell it which info to save? is this indicator going to one string variable that i include in the names of the tables affected so that i use an IF statement? if so, what do i use to find the string inside that variable? or if not, please recommend a scenario?

Answer : SQL Server - How to find a string inside a variable?

Try using CharIndex.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
-- Example of using CharIndex.  This example
-- returns 17, the starting position of 'fox'
DECLARE @s varchar(500),
		@Pos int

SET @s = 'The quick brown fox jumped over the lazy dog.'

SET @Pos = CHARINDEX('fox', @s)

SELECT @Pos
Random Solutions  
 
programming4us programming4us