Viewing 15 posts - 1,096 through 1,110 (of 1,439 total)
If you run this
select *
from MyTable
where exists (select * from MyTable t
where t.ObjectId=MyTable.ObjectId
and t.DataKey=MyTable.DataKey
and t.IdentCol>MyTable.IdentCol)
it should show you the rows that are to be deleted. The query simply returns rows...
June 30, 2009 at 10:16 am
delete
from MyTable
where exists (select * from MyTable t
where t.ObjectId=MyTable.ObjectId
...
June 30, 2009 at 9:53 am
Maybe this?
select hostname from master.dbo.sysprocesses where spid=@@spid
June 29, 2009 at 4:46 am
Mark (6/26/2009)
Use LIKE
declare @s varchar(9)--set @s='ab1234567'
set @s='ab123456x'
if @s not like '__[0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
print 'Not Numeric'
Also for variable width string,
if substring(@s,3,7) like '%[^0-9]%'
print 'Not Numeric'
June 26, 2009 at 9:56 am
Use LIKE
declare @s varchar(9)
--set @s='ab1234567'
set @s='ab123456x'
if @s not like '__[0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
print 'Not Numeric'
June 26, 2009 at 9:51 am
Another way...
WITH OrderedCTE AS (
SELECT ID,
KEYID,
VALUE_STR,
ROW_NUMBER()OVER(PARTITION BY KEYID ORDER...
June 26, 2009 at 2:24 am
ASCII '0A' is '\ n' not '\r', try changing the ROWTERMINATOR
June 18, 2009 at 10:02 am
Can enrollment dates overlap, such as this?
Insert Into tbl_Cli_Insu(ClientID, eff_dt, exp_dt) Values (9, '20080101', '20080301')
Insert Into tbl_Cli_Insu(ClientID, eff_dt, exp_dt) Values (9, '20080201', '20080501')
Insert Into tbl_Cli_Insu(ClientID, eff_dt, exp_dt) Values (9, '20080401',...
June 17, 2009 at 7:16 am
It's not really clear how LineNo joins, but this gives the correct result.
WITH Questions(Contact,[LineNo],LineNoMax,Question) AS (
SELECT a.Contact,a.[LineNo],MIN(b.[LineNo])-1,a.Question
FROM #Question a
LEFT OUTER JOIN #Question b ON b.Contact=a.Contact AND b.[LineNo]>a.[LineNo]
GROUP BY a.Contact,a.[LineNo],a.Question)
SELECT a.Contact,a.Question,b.Answer
FROM...
June 16, 2009 at 6:10 am
See if this helps
DECLARE @Jobs TABLE(Street VARCHAR(10), Seq INT)
INSERT INTO @Jobs(Street, Seq)
SELECT 'Street A',1 UNION ALL
SELECT 'Street A',2 UNION ALL
SELECT 'Street A',3 UNION ALL
SELECT 'Street A',4 UNION ALL
SELECT 'Street A',5...
June 12, 2009 at 8:36 am
See this thread
http://www.sqlservercentral.com/Forums/FindPost693820.aspx
For example
WITH CTE AS (
SELECT Doctor_Id,
Tests,
ROW_NUMBER() OVER(PARTITION BY Doctor_Id...
June 12, 2009 at 3:27 am
Using EXCEPT will give you pairs in Table1 that aren't in Table2
SELECT [Cust#],CustName FROM Table1
EXCEPT
SELECT [Cust#],CustName FROM Table2
June 10, 2009 at 7:57 am
Maybe this?
with cte as (
select Col1
, Col2
, Col3
, Col4
from MyTable
)
select case when @input_variable = 1 then sum(Col1)
when...
June 8, 2009 at 9:18 am
You could use the SIGN function, but I can't think why you would use this in preference to "<0"
June 8, 2009 at 8:11 am
You may find it easier to use an OUTPUT clause in the INSERT statement
.
.
INSERT INTO [dbo].[tbl_Users] ( [lotsOfColumns] )
OUTPUT inserted.userid ...
June 8, 2009 at 8:09 am
Viewing 15 posts - 1,096 through 1,110 (of 1,439 total)