SQL query search

banu111
banu111 used Ask the Experts™
on
HI friends
I have function  GetValue( string id)
I am passing id=abcd
I want to assign to a variable  if abcd is present in the databse
but abcd   is stored as abcd@MCKTESTAD.local
in database. I want to search the database exactly the row which contains
id@(abcd )  in the beginning and  assign that value to variable. How can I do that
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Database Consultant
Top Expert 2009
Commented:
select @localVariable = id
from yourtable
where column like @inputVariable+'%'
Anuradha GoliSystems Development / Support Specialist

Commented:
To get data from SQL Server which matches string starts with ''id@(abcd )' is:

Declare @data nvarchar(50)
set @data = 'abcd@MCKTESTAD.local'
SELECT * FROM TableA WHERE COLUMN1 LIKE 'id@(abcd )%'

Open in new window

AneeshDatabase Consultant
Top Expert 2009

Commented:
You should probably change your Grading strategy. I hope i gave you the perfect answer.

Author

Commented:
but if have two users abcd@MCKTESTAD.local and abcd@MCKTESTAD.local will it wrk

Author

Commented:
sry abcd1@MCKTESTAD.local

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial