Showing posts with label mssql. Show all posts
Showing posts with label mssql. Show all posts

Friday, March 23, 2012

find_in_set in mssql?

Hello,
i try to migrate from MySQL to MSSQL.
i have a query like
SELECT [...] FIND_IN_SET(id, "1,53,82,102,435") [...]
but MSSQL don't know the string function "FIND_IN_SET".
My question is now,
is there a FIND_IN_SET-like function for MSSQL ?
for those who not know what FIND_IN_SET do:
FIND_IN_SET(str, str_list)
str_list is a string list consiting of substrings separated by commas.
FIND_IN_SET returns the index of "str" within "str_list".
Example:
SELECT FIND_IN_SET("2", "0,1,2,3,4");
Returns: 3
Thanks in advance
jg
Try this:
Select [..] from MyTable where id in (1,53,82,102,435)
Amol.
"jg" <anonymous@.discussions.microsoft.com> wrote in message
news:7C4E7C09-5C85-44B6-ABC1-EA9F2BE20A94@.microsoft.com...
> Hello,
> i try to migrate from MySQL to MSSQL.
> i have a query like
> SELECT [...] FIND_IN_SET(id, "1,53,82,102,435") [...]
> but MSSQL don't know the string function "FIND_IN_SET".
> My question is now,
> is there a FIND_IN_SET-like function for MSSQL ?
> for those who not know what FIND_IN_SET do:
> FIND_IN_SET(str, str_list)
> str_list is a string list consiting of substrings separated by commas.
> FIND_IN_SET returns the index of "str" within "str_list".
> Example:
> SELECT FIND_IN_SET("2", "0,1,2,3,4");
> Returns: 3
> Thanks in advance
> jg
>
|||Hello Amol,
thank you for your reply, but in(...) is for the "where" clause.
FIND_IN_SET is for SELECT.
For better understanding my complete query
--8<--8<--8<--8<--
select testtable.*,username as c_user_name
,find_in_set(id,"4,5,6,48,71,2086,264,1711") as order_id
from testtable
left join auth_user on c_user=auth_user.user_id
where id in(4,5,6,48,71,2086,264,1711) and (
rel_user_group.user_id='86d87875860b03862a3e4f52e7 54fad7'
and (
1=0
or ( (rel_user_group.group_id=perm_edit or perm_edit='') and (rel_user_group.role_id=role_edit or role_edit='') )
or ( (rel_user_group.group_id=perm_child or perm_child='') and (rel_user_group.role_id=role_child or role_child='') )
or rel_user_group.group_id='707b826f242b92e278803c605 ef81e18'
or owner_id='86d87875860b03862a3e4f52e754fad7'
)
)
order by id,order_id
--8<--8<--8<--
This query sort all returning rows by order_id. order_id is generated automaticaly with the FIND_IN_SET instruction. (It contains the values 1, 2, 3, 4, ...)
Thanks for all your help.
jg
|||You can write a function that does this for you.
"jg" <anonymous@.discussions.microsoft.com> wrote in message
news:DFED7D30-FFAA-4D97-B49F-A2EC285BF762@.microsoft.com...
> Hello Amol,
> thank you for your reply, but in(...) is for the "where" clause.
> FIND_IN_SET is for SELECT.
> For better understanding my complete query
> --8<--8<--8<--8<--
> select testtable.*,username as c_user_name
> ,find_in_set(id,"4,5,6,48,71,2086,264,1711") as order_id
> from testtable
> left join auth_user on c_user=auth_user.user_id
> where id in(4,5,6,48,71,2086,264,1711) and (
> rel_user_group.user_id='86d87875860b03862a3e4f52e7 54fad7'
> and (
> 1=0
> or ( (rel_user_group.group_id=perm_edit or perm_edit='') and
(rel_user_group.role_id=role_edit or role_edit='') )
> or ( (rel_user_group.group_id=perm_child or perm_child='') and
(rel_user_group.role_id=role_child or role_child='') )
> or rel_user_group.group_id='707b826f242b92e278803c605 ef81e18'
> or owner_id='86d87875860b03862a3e4f52e754fad7'
> )
> )
> order by id,order_id
> --8<--8<--8<--
> This query sort all returning rows by order_id. order_id is generated
automaticaly with the FIND_IN_SET instruction. (It contains the values 1, 2,
3, 4, ...)
> Thanks for all your help.
> jg
>

find_in_set in mssql?

Hello,
i try to migrate from mysql to MSSQL.
i have a query like
SELECT [...] FIND_IN_SET(id, "1,53,82,102,435") [...]
but MSSQL don't know the string function "FIND_IN_SET".
My question is now,
is there a FIND_IN_SET-like function for MSSQL ?
for those who not know what FIND_IN_SET do:
FIND_IN_SET(str, str_list)
str_list is a string list consiting of substrings separated by commas.
FIND_IN_SET returns the index of "str" within "str_list".
Example:
SELECT FIND_IN_SET("2", "0,1,2,3,4");
Returns: 3
Thanks in advance
jgTry this:
Select [..] from MyTable where id in (1,53,82,102,435)
Amol.
"jg" <anonymous@.discussions.microsoft.com> wrote in message
news:7C4E7C09-5C85-44B6-ABC1-EA9F2BE20A94@.microsoft.com...
> Hello,
> i try to migrate from mysql to MSSQL.
> i have a query like
> SELECT [...] FIND_IN_SET(id, "1,53,82,102,435") [...]
> but MSSQL don't know the string function "FIND_IN_SET".
> My question is now,
> is there a FIND_IN_SET-like function for MSSQL ?
> for those who not know what FIND_IN_SET do:
> FIND_IN_SET(str, str_list)
> str_list is a string list consiting of substrings separated by commas.
> FIND_IN_SET returns the index of "str" within "str_list".
> Example:
> SELECT FIND_IN_SET("2", "0,1,2,3,4");
> Returns: 3
> Thanks in advance
> jg
>|||Hello Amol,
thank you for your reply, but in(...) is for the "where" clause.
FIND_IN_SET is for SELECT.
For better understanding my complete query
--8<--8<--8<--8<--
select testtable.*,username as c_user_name
,find_in_set(id,"4,5,6,48,71,2086,264,1711") as order_id
from testtable
left join auth_user on c_user=auth_user.user_id
where id in(4,5,6,48,71,2086,264,1711) and (
rel_user_group. user_id='86d87875860b03862a3e4f52e754fad
7'
and (
1=0
or ( (rel_user_group.group_id=perm_edit or perm_edit='') and (rel_user_grou
p.role_id=role_edit or role_edit='') )
or ( (rel_user_group.group_id=perm_child or perm_child='') and (rel_user_gr
oup.role_id=role_child or role_child='') )
or rel_user_group. group_id='707b826f242b92e278803c605ef81e
18'
or owner_id='86d87875860b03862a3e4f52e754fa
d7'
)
)
order by id,order_id
--8<--8<--8<--
This query sort all returning rows by order_id. order_id is generated automa
ticaly with the FIND_IN_SET instruction. (It contains the values 1, 2, 3, 4,
...)
Thanks for all your help.
jg|||You can write a function that does this for you.
"jg" <anonymous@.discussions.microsoft.com> wrote in message
news:DFED7D30-FFAA-4D97-B49F-A2EC285BF762@.microsoft.com...
> Hello Amol,
> thank you for your reply, but in(...) is for the "where" clause.
> FIND_IN_SET is for SELECT.
> For better understanding my complete query
> --8<--8<--8<--8<--
> select testtable.*,username as c_user_name
> ,find_in_set(id,"4,5,6,48,71,2086,264,1711") as order_id
> from testtable
> left join auth_user on c_user=auth_user.user_id
> where id in(4,5,6,48,71,2086,264,1711) and (
> rel_user_group. user_id='86d87875860b03862a3e4f52e754fad
7'
> and (
> 1=0
> or ( (rel_user_group.group_id=perm_edit or perm_edit='') and
(rel_user_group.role_id=role_edit or role_edit='') )
> or ( (rel_user_group.group_id=perm_child or perm_child='') and
(rel_user_group.role_id=role_child or role_child='') )
> or rel_user_group. group_id='707b826f242b92e278803c605ef81e
18'
> or owner_id='86d87875860b03862a3e4f52e754fa
d7'
> )
> )
> order by id,order_id
> --8<--8<--8<--
> This query sort all returning rows by order_id. order_id is generated
automaticaly with the FIND_IN_SET instruction. (It contains the values 1, 2,
3, 4, ...)
> Thanks for all your help.
> jg
>

find_in_set in mssql?

Hello
i try to migrate from MySQL to MSSQL
i have a query lik
SELECT [...] FIND_IN_SET(id, "1,53,82,102,435") [...
but MSSQL don't know the string function "FIND_IN_SET"
My question is now
is there a FIND_IN_SET-like function for MSSQL
for those who not know what FIND_IN_SET do
FIND_IN_SET(str, str_list
str_list is a string list consiting of substrings separated by commas
FIND_IN_SET returns the index of "str" within "str_list"
Example
SELECT FIND_IN_SET("2", "0,1,2,3,4")
Returns:
Thanks in advanc
jTry this:
Select [..] from MyTable where id in (1,53,82,102,435)
Amol.
"jg" <anonymous@.discussions.microsoft.com> wrote in message
news:7C4E7C09-5C85-44B6-ABC1-EA9F2BE20A94@.microsoft.com...
> Hello,
> i try to migrate from MySQL to MSSQL.
> i have a query like
> SELECT [...] FIND_IN_SET(id, "1,53,82,102,435") [...]
> but MSSQL don't know the string function "FIND_IN_SET".
> My question is now,
> is there a FIND_IN_SET-like function for MSSQL ?
> for those who not know what FIND_IN_SET do:
> FIND_IN_SET(str, str_list)
> str_list is a string list consiting of substrings separated by commas.
> FIND_IN_SET returns the index of "str" within "str_list".
> Example:
> SELECT FIND_IN_SET("2", "0,1,2,3,4");
> Returns: 3
> Thanks in advance
> jg
>|||Hello Amol
thank you for your reply, but in(...) is for the "where" clause
FIND_IN_SET is for SELECT
For better understanding my complete quer
--8<--8<--8<--8<--
select testtable.*,username as c_user_nam
,find_in_set(id,"4,5,6,48,71,2086,264,1711") as order_i
from testtabl
left join auth_user on c_user=auth_user.user_i
where id in(4,5,6,48,71,2086,264,1711) and (
rel_user_group.user_id='86d87875860b03862a3e4f52e754fad7
and
1=or ( (rel_user_group.group_id=perm_edit or perm_edit='') and (rel_user_group.role_id=role_edit or role_edit='')
or ( (rel_user_group.group_id=perm_child or perm_child='') and (rel_user_group.role_id=role_child or role_child='')
or rel_user_group.group_id='707b826f242b92e278803c605ef81e18
or owner_id='86d87875860b03862a3e4f52e754fad7
order by id,order_i
--8<--8<--8<--
This query sort all returning rows by order_id. order_id is generated automaticaly with the FIND_IN_SET instruction. (It contains the values 1, 2, 3, 4, ...
Thanks for all your help
j|||You can write a function that does this for you.
"jg" <anonymous@.discussions.microsoft.com> wrote in message
news:DFED7D30-FFAA-4D97-B49F-A2EC285BF762@.microsoft.com...
> Hello Amol,
> thank you for your reply, but in(...) is for the "where" clause.
> FIND_IN_SET is for SELECT.
> For better understanding my complete query
> --8<--8<--8<--8<--
> select testtable.*,username as c_user_name
> ,find_in_set(id,"4,5,6,48,71,2086,264,1711") as order_id
> from testtable
> left join auth_user on c_user=auth_user.user_id
> where id in(4,5,6,48,71,2086,264,1711) and (
> rel_user_group.user_id='86d87875860b03862a3e4f52e754fad7'
> and (
> 1=0
> or ( (rel_user_group.group_id=perm_edit or perm_edit='') and
(rel_user_group.role_id=role_edit or role_edit='') )
> or ( (rel_user_group.group_id=perm_child or perm_child='') and
(rel_user_group.role_id=role_child or role_child='') )
> or rel_user_group.group_id='707b826f242b92e278803c605ef81e18'
> or owner_id='86d87875860b03862a3e4f52e754fad7'
> )
> )
> order by id,order_id
> --8<--8<--8<--
> This query sort all returning rows by order_id. order_id is generated
automaticaly with the FIND_IN_SET instruction. (It contains the values 1, 2,
3, 4, ...)
> Thanks for all your help.
> jg
>

Sunday, February 26, 2012

Find database access by tcp connection

Ok, lets see if I can put what I am looking for into words.
I run a MSSQL server, I show in my logs that a connection is being made to my server from a remote ip. I have contact the owner of the ip in question and they state that they have no buisness with us and they should not be connected to us. According to netstat the connection to us is established on 2 different remote ports to 1433. My question, is there any logging on sql that I can turn on, look at to see what database this connection is accessing? ThanksHow about the windows event viewer or sql profiler..

However...how are they connecting id they do not have a login?|||Originally posted by Brett Kaiser
How about the windows event viewer or sql profiler..

However...how are they connecting id they do not have a login?

They must have a userid and password to connect yes, I am trying to find out who it is. None of our clients that I know of are connecting from this location. I'm not familiar with the sql profiler. Where might this be.

Thanks|||It comes with the sql server client tools...

And this guy gave a presentation on it...

http://weblogs.sqlteam.com/billg/archive/2003/11/08/460.aspx|||Hmm. You are really plugging those weblogs these days, Brett ;-). <opening>But I bet I can't find a decent recipe for a margarita there.</opening>

What logs are showing the connections? Do you have success auditing for security turned on on the server?|||Originally posted by MCrowley
Hmm. You are really plugging those weblogs these days, Brett ;-). <opening>But I bet I can't find a decent recipe for a margarita there.</opening>

What logs are showing the connections? Do you have success auditing for security turned on on the server?

Is this a setup?

http://weblogs.sqlteam.com/brettk/archive/2003/10/02/223.aspx

Friday, February 24, 2012

Find a name of an index in deadlock situation.

Hi
I have a deadlock occurring.
Using MSSQL 2005 current activity lock screens I can see one process is
waiting for a lock to be released on a Database object. with objectId =
1441294802092032 and type = KEY - so I know I have a lock on an Index
and what table the index belongs to,
But how can I find the name of the index that is blocked?
This was part of the default view in SQL2000 activity manager. I cannot
use object_name (1441294802092032 ).
Pain is cannot even export the details of the locks per process to a
file.
Yitzak
http://blogs.msdn.com/bartd/archive/2006/09/09/747119.aspx
"Yitzak" <terryshamir@.yahoo.co.uk> wrote in message
news:1164814916.178901.38620@.16g2000cwy.googlegrou ps.com...
> Hi
> I have a deadlock occurring.
> Using MSSQL 2005 current activity lock screens I can see one process is
> waiting for a lock to be released on a Database object. with objectId =
> 1441294802092032 and type = KEY - so I know I have a lock on an Index
> and what table the index belongs to,
> But how can I find the name of the index that is blocked?
> This was part of the default view in SQL2000 activity manager. I cannot
> use object_name (1441294802092032 ).
> Pain is cannot even export the details of the locks per process to a
> file.
>

Find a name of an index in deadlock situation.

Hi
I have a deadlock occurring.
Using MSSQL 2005 current activity lock screens I can see one process is
waiting for a lock to be released on a Database object. with objectId = 1441294802092032 and type = KEY - so I know I have a lock on an Index
and what table the index belongs to,
But how can I find the name of the index that is blocked'
This was part of the default view in SQL2000 activity manager. I cannot
use object_name (1441294802092032 ).
Pain is cannot even export the details of the locks per process to a
file.Yitzak
http://blogs.msdn.com/bartd/archive/2006/09/09/747119.aspx
"Yitzak" <terryshamir@.yahoo.co.uk> wrote in message
news:1164814916.178901.38620@.16g2000cwy.googlegroups.com...
> Hi
> I have a deadlock occurring.
> Using MSSQL 2005 current activity lock screens I can see one process is
> waiting for a lock to be released on a Database object. with objectId => 1441294802092032 and type = KEY - so I know I have a lock on an Index
> and what table the index belongs to,
> But how can I find the name of the index that is blocked'
> This was part of the default view in SQL2000 activity manager. I cannot
> use object_name (1441294802092032 ).
> Pain is cannot even export the details of the locks per process to a
> file.
>

Find a name of an index in deadlock situation.

Hi
I have a deadlock occurring.
Using MSSQL 2005 current activity lock screens I can see one process is
waiting for a lock to be released on a Database object. with objectId =
1441294802092032 and type = KEY - so I know I have a lock on an Index
and what table the index belongs to,
But how can I find the name of the index that is blocked'
This was part of the default view in SQL2000 activity manager. I cannot
use object_name (1441294802092032 ).
Pain is cannot even export the details of the locks per process to a
file.Yitzak
http://blogs.msdn.com/bartd/archive.../09/747119.aspx
"Yitzak" <terryshamir@.yahoo.co.uk> wrote in message
news:1164814916.178901.38620@.16g2000cwy.googlegroups.com...
> Hi
> I have a deadlock occurring.
> Using MSSQL 2005 current activity lock screens I can see one process is
> waiting for a lock to be released on a Database object. with objectId =
> 1441294802092032 and type = KEY - so I know I have a lock on an Index
> and what table the index belongs to,
> But how can I find the name of the index that is blocked'
> This was part of the default view in SQL2000 activity manager. I cannot
> use object_name (1441294802092032 ).
> Pain is cannot even export the details of the locks per process to a
> file.
>