Getting Rid Of Everything After Underscore?
Sep 11, 2013I have data that looks like this:
CAT_DOG
MICE_CAT
RABBIT_DOG
LION_MICE
I want a select clause that will give me just this:
CAT
MICE
RABBIT
LION
I have data that looks like this:
CAT_DOG
MICE_CAT
RABBIT_DOG
LION_MICE
I want a select clause that will give me just this:
CAT
MICE
RABBIT
LION
Hi friends,
I got troubles when I tried to pass table name to sp_columns via
@local_variable:
declare @tname as char(50)
set @tname = 'TB_MyTable'
exec sp_columns @tname
result of such script is:
TABLE_QUALIFIER ...[skipped]
-----------------------------------
(0 row(s) affected)
But if I will say:
exec sp_columns 'TB_MyTable'
result will be correct (all neccessary data about columns will be provided)
So, looks like if I pass table name which contains underscore via
@local_variable or SP parameter - result will be wrong.
If table name won't contains underscore - everything works fine and result
of script:
declare @tname as char(50)
set @tname = 'MyTable'
exec sp_columns @tname
will be absolutely correct.
Please, anybody can clarify this situation ???
Thanks in advance,
Michael
I'm attempting to doing a search of the db for all name entries with the underscore character "_".
I use %_% and get all the entries.
What am I doing wrong?
Help .... thanks!
Hello All,DDL Statements:CREATE TABLE [dbo].[Table1] ([MyDate] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL) ON [PRIMARY]GOI have a varchar column which represents dates in YYYYMMDD and MM/DD/YYformats. If I query using:SELECT MyDate FROM Table1WHERE DOB LIKE '________'Why aren't the dates in MM/DD/YY returned ? Is the / a specialcharacter in T-SQL ?Thanks in advance
View 1 Replies View RelatedIn MS Sql 2000 - is it possible to find the literal underscore character (_). Something like:
SELECT * FROM foo WHERE bar like 'a\_%'
where the query would return "a_abc", "a_cba", and "a_lksdfjlkdsjlksjdfl", but not "abc"?
I've tried:
SELECT * FROM foo WHERE bar like 'a\_%'
SELECT * FROM foo WHERE bar like ( 'a' + CHAR(95) + '%' )
Any other suggestions?
I have made a stored procedure, it makes successfully when created, but when I open it in modify, there is a red underscore under the procedure name.
When I place the courser over the red underscore, the massage is "Invalid object name"
I have filenames and I want to get a substring of the file name up to the last underscore if it exists and if not up to the last period.
Create table FileNames (fileName varchar(40))
insert into FileNames values ('this_is_a_long_filename.ext')
insert into FileNames values ('this_is_an_even_longer_filename.ext')
insert into FileNames values ('short_filename.ext')
insert into FileNames values ('supershort.ext')
What I want returned is:
this_is_a_long
this_is_an_even_longer
short
supershort
I want to establish logging using NT Security. The problem is that user names in NT have underscore(_). When I establish NT Scurity in SQL security manager, SQL Server tries to add blank names as login id and they will not go through. Is it manadatory to remove underscore from username?
Because of structrual hierarchy, I have different groups in NT to be mapped to SQL Server groups and each group has different permission on SQL tables. In some cases we might have same users in more than one group. I read that it is not possible if you use NT integrated security. Is there any thing that can be worked around this and is this problem still exists in SQL 7.
Thank you in advance
Ali Malekshahi
Hi Gurus,
How do I write a T-SQL function for a string before a underscore is found?
Thanks Gurus.
I have data like ABC_Tablename_12345, i just want everything before and after _ also if there is no underscore in the name just return the name.
View 2 Replies View RelatedHello,
I want to search a column with all the words deliminate by underscore. E.g. User_id, Community_name, author_id and etc.
It seems like freetext only deal with string with blank deliminator. How should I do the rull text search on column like this? Here is the code.declare @var varchar(2000)
set @var = 'id'
select [name], definition,version_code
from dbo.base
where freetext([name],@var)
thx