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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 TO DISPLAY NAMES

Author  Topic 

Arun.G
Yak Posting Veteran

81 Posts

Posted - 2010-07-27 : 09:05:30

THE BELOW IS MY STOREDPROCEDURE:

CREATE PROCEDURE [dbo].[SP_RES_SEARCH]
-- The below are the input arguments for calling the procedure

@EMP_NAME varchar(100)

AS

SELECT
UPPER(FIRSTNAME)
FROM
DATATABLE
WHERE
FIRSTNAME LIKE '@EMP_NAME %'

this executed successfully, but not displyaing the output

but i used the same query and instead of @emp_name=A
means , its working fine



how should i give the input argument in like condition?


i tried this

@EMP_NAME + '%''', but not working

pls help.


SELECT
UPPER(PI_FIRSTNAME)
FROM
PNET_PFILE_DATATABLE1
WHERE
PI_FIRSTNAME LIKE 'A%'

then it display firstanem starting as "A"

Sachin.Nand

2937 Posts

Posted - 2010-07-27 : 09:13:02
Create dynamic SQL like this


@sql='SELECT
UPPER(FIRSTNAME)
FROM
DATATABLE
WHERE
FIRSTNAME LIKE' + @EMP_NAME + '%'
Exec(@sql)





Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless.

PBUH
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-07-27 : 09:14:27
[code]SELECT
UPPER(FIRSTNAME)
FROM
DATATABLE
WHERE
FIRSTNAME LIKE @EMP_NAME + '%'[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-07-28 : 06:43:41
quote:
Originally posted by Idera

Create dynamic SQL like this


@sql='SELECT
UPPER(FIRSTNAME)
FROM
DATATABLE
WHERE
FIRSTNAME LIKE' + @EMP_NAME + '%'
Exec(@sql)





Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless.

PBUH


You dont need a dynamic sql as you dont pass any object names as variables

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -