fix a where clause
WHERE dbo.tblEmployerName.EmpName = @prmEmployerName or @prmEmployerName IS NULL I like the user to be able to enter part of the employer name I need to put a like. and if it the parameter is null extract all employers Mathieu Alexandre Cupryk www.omegalove.com
May 9th, 2011 3:32pm

Have you thought about dynamic sql? you would create the WHERE clause based on the user input parameters. - will
Free Windows Admin Tool Kit Click here and download it now
May 9th, 2011 3:45pm

Hi Mathieu, Have you tried something as below t-sql script: DECLARE @ST VARCHAR(10) SET @ST = 'NAME' --NULL CREATE TABLE #TEMP ( ST VARCHAR(10) NULL ) INSERT INTO #TEMP VALUES ( 'abcNAMEdef' ) INSERT INTO #TEMP VALUES ( 'abcuvw' ) INSERT INTO #TEMP VALUES ( 'abcpqr' ) INSERT INTO #TEMP VALUES ( 'abcNAMExyz' ) SELECT ST FROM #TEMP WHERE ST LIKE '%' + ISNULL( @ST, ST ) + '%' DROP TABLE #TEMP Thanks KumarKG, MCTS
May 9th, 2011 4:03pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics