Posted by: ayhan | 12/02/2015

SQL PATINDEX

Sql sorgularında parametre olarak birden fazla değer gönderebilmek için kullanılabilecek bir sorgu yazım şekli

DECLARE @UserIds VARCHAR(50) = ‘4,5,7,8’
SELECT * FROM Users
WHERE PATINDEX(‘%,’ + CAST(Id as varchar(20)) + ‘,%’, ‘,’ + @UserIds + ‘,’) > (CASE @UserIds WHEN ” THEN -1 ELSE 0 END)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: