Viewing 15 posts - 1,216 through 1,230 (of 1,439 total)
Something like this?
declare @pattern varchar(10)
declare @s varchar(255)
set @pattern='[0-9])'
set @s = 'ABC0)1)22)33))XYZ4)5689'
select count(*)
from numbers
where substring(@s,number,len(@s)) like @pattern+'%'
and number between 1 and len(@s)
February 9, 2009 at 3:52 am
see if this helps
declare @string varchar(30)
set @string = '$4.21 plus tax....'
select left(@string,1+len(@string)-patindex('%[^.]%',reverse(@string)))
February 4, 2009 at 11:39 am
try this
WITH CTE AS (
SELECT id,name,parent_id, 1 AS Level, CAST(name AS VARCHAR(MAX)) AS FullPath
FROM mytable
WHERE parent_id = 0
UNION ALL
SELECT t.id,t.name,t.parent_id, c.Level+1, CAST(t.name AS VARCHAR(MAX)) +',' + c.FullPath
FROM mytable t
INNER JOIN...
February 4, 2009 at 9:08 am
see if this helps
CREATE TABLE tabl1(
EmpId INT,
Emp_Name VARCHAR(20),
ManagerID ...
February 3, 2009 at 2:40 am
WITH CTE AS (
SELECT EMPL_ID, effective_dt, ORG,
ROW_NUMBER() OVER(PARTITION BY EMPL_ID ORDER BY effective_dt DESC) AS rn
FROM ORG)
SELECT EMPL_ID, effective_dt, ORG
FROM CTE
WHERE...
February 2, 2009 at 2:16 pm
@GasSiteId should be @GasSiteID (XML is case-sensitive)
January 28, 2009 at 9:27 am
WITH CTE(ColID,ParentColID,ColVal,fullpath) AS (
SELECT ColID,ParentColID,ColVal,CAST(ColVal AS VARCHAR(MAX))
FROM #tmp1
WHERE ParentColID IS NULL
UNION ALL
SELECT p.ColID , p.ParentColID ,p.ColVal, c.fullpath+'/'+CAST(p.ColVal AS VARCHAR(MAX))
FROM CTE c
INNER JOIN #tmp1 p ON p.ParentColID=c.ColID)
SELECT ColID,ParentColID,ColVal
FROM CTE
ORDER BY fullpath
January 28, 2009 at 5:23 am
This isn't particularly efficient, but should work okay
WITH LBounds AS(
SELECT s1.ItemCode,s1.Units,s1.Place,s1.Status,s1.StartDate,s1.Flag
FROM mytable s1
WHERE NOT EXISTS(SELECT * FROM mytable s2
...
January 27, 2009 at 3:04 am
select substring(@vch,patindex('%[0-9]%',@vch),100)
January 27, 2009 at 12:47 am
select ItemNo,
sum(case when Date1 > Date2 then 1 else 0 end),
count(*)
from Table
group by ItemNo
January 26, 2009 at 8:15 am
Mahesh Bote (1/16/2009)
Delete From Store
Where Store.Metadata.exist('/author[not(contains(., "Per Bothner"))]') >= 0
It should delete those elements whos author is other than...
January 16, 2009 at 7:46 am
select object_name(object_id) as tablename, name as columnname,collation_name
from sys.columns
where collation_name is not null
order by object_name(object_id),column_id
January 14, 2009 at 2:54 am
Jeff Moden (1/13/2009)
VERY clever code... I obviously never thought of using PatIndex and a variable for the first character of a range... And, it's about twice as fast as the...
January 13, 2009 at 7:24 am
Sergei Ely (1/12/2009)
Thanks for the input. The solution requires placement of the integer within the ordered string at variable positions. For example, the existing string could be a single...
January 13, 2009 at 2:11 am
Here's another way.
SELECT CASE WHEN CHARINDEX(@CharToInsert,@ExistingString) > 0
THEN @ExistingString
...
January 12, 2009 at 2:59 am
Viewing 15 posts - 1,216 through 1,230 (of 1,439 total)