Viewing 15 posts - 61 through 75 (of 89 total)
hi,
the syntax error might be cause of table is not exists please create table which is commented,
Logic: in first cte I find out the chain depends upon the col1.
and...
May 6, 2010 at 12:25 am
CREATE PROC usp_procdetails
@Param1 INT = 1
@Param2 VARCHAR(100) = 'Default'--This can work by adding value also.
AS
BEGIN
--Add your code depends upon default.
END
GO
EXEC usp_procdetails
GO
April 12, 2010 at 3:40 am
DECLARE @tbl_Duplicate TABLE
(
ID INT
)
INSERT INTO @tbl_Duplicate VALUES(1),(2),(1),(3)
--Before
SELECT * FROM @tbl_Duplicate
;WITH CTE AS
(
SELECT
ROW_NUMBER() OVER(PARTITION BY ID ORDER BY ID) AS ROWID
FROM
@tbl_Duplicate
)
DELETE FROM CTE WHERE ROWID > 1
--AFTER
SELECT * FROM...
April 12, 2010 at 1:41 am
DROP TABLE #t
create table #t(customernumber varchar(10), notes varchar(10), lastvisitdate smalldatetime)
insert into #t values(100000, 'text 1', '10.feb.2010')
insert into #t values(100000, 'text 2', '10.feb.2010')
insert into #t values(100000, 'text 3', '10.feb.2010')
select customernumber+', '+CONVERT(VARCHAR(20),lastvisitdate,106)+'...
March 24, 2010 at 7:12 am
DECLARE @tblA TABLE
(
IDINT
)
DECLARE @tblB TABLE
(
IDINT
)
DECLARE @tblC TABLE
(
IDINT
)
INSERT INTO @tblA
SELECT 1
UNION ALL
SELECT 2 UNION ALL
SELECT 3 UNION ALL
SELECT 4 UNION ALL
SELECT 5
INSERT INTO @tblB
SELECT 1
UNION ALL
SELECT 2
INSERT INTO @tblC
SELECT 3...
February 10, 2010 at 4:33 am
IF ( OBJECT_ID( 'tempdb..#Databases' ) IS NOT NULL )
DROP TABLE #Databases
CREATE TABLE #Databases
(
...
February 6, 2010 at 3:12 am
DECLARE @tbl TABLE
(
File_Names VARCHAR(100)
)
INSERT INTO @tbl
exec master.dbo.xp_cmdshell 'dir c:\*.xml /b'
SELECT * FROM @tbl WHERE File_NamesLIKE'%xml%'
January 28, 2010 at 9:48 pm
as per requirment first and Last Records Records with 0 days.
SELECT Cd.*,DATEDIFF(dd,CD.End_Date,ISNULL(CE.Start_Date,CD.End_Date)) AS Day_DIFF FROM #Care_EpisodesCD
LEFT JOIN
#Care_EpisodesCE
ON
CD.PKID=CE.PKID-1AND
CD.Person_ID=CE.Person_ID
January 28, 2010 at 9:39 pm
--create table abc(col1 varchar(20),col2 varchar(20))
--
--insert into abc values('5.N.1','5.N.4')
--insert into abc values('5.N.4','5.N.5')
--insert into abc values('5.N.5','5.N.6')
--insert into abc values('5.N.6','5.N.9')
--insert into abc values('5.N.1','5.N.10')
--insert into abc values('5.N.2','5.N.4')
--insert into abc values('5.N.10','5.N.11')
--insert into abc...
January 27, 2010 at 11:32 pm
DECLARE @tbl TABLE
(
EMPIDINT,
EmpNameVARCHAR(100)
)
INSERT INTO @tbl
SELECT
1, 'aaa'
UNION ALL
SELECT
1, 'aaa'
UNION ALL
SELECT
2, 'aaa'
UNION ALL
SELECT
3, 'bbb'
UNION ALL
SELECT
2, 'bbb'
DELETE D FROM
(
SELECT
ROW_NUMBER() OVER(PARTITION BY EMPID,EmpName ORDER BY EMPID) AS ROWS,
EMPID,
EmpName
FROM
@tbl
)D
WHERE
ROWS> 1
SELECT * FROM @tbl
January 27, 2010 at 10:56 pm
DECLARE @table table
(
IDVARCHAR(100),
DATETIME1DATETIME
)
INSERT INTO @table
SELECT
'AI1', 40001
UNION ALL
SELECT
'AI1', 40002
UNION ALL
SELECT
'AI1' ,40003
UNION ALL
SELECT
'AI1' ,40004
UNION ALL
SELECT
'AI1', 40005
UNION ALL
SELECT
'AI1', 40006
UNION ALL
SELECT
'AI2', 41001
UNION ALL
SELECT
'AI2', 41002
UNION ALL
SELECT
'AI2', 41003
UNION ALL
SELECT
'AI2', 41004
UNION ALL
SELECT
'AI2', 41005
UNION ALL
SELECT
'AI2', 41006
UNION ALL
SELECT
'AI3',...
January 27, 2010 at 6:57 am
DECLARE @Temp TABLE(version_id int,customer_id char(8),product_id char(20),month_id char(2),fiscal_year char(2),units numeric(18, 4),value numeric(18, 4))
INSERT INTO @Temp
SELECT
1,'1','10','1','00',100,980.66
UNION ALL
SELECT
15,'1','10','12','00',100,980.66
UNION ALL
SELECT
14,'1','10','10','00',100,980.66
UNION ALL
SELECT
13,'1','10','11','00',100,980.66
UNION ALL
SELECT
1,'1','10','1','00',100,980.66
UNION ALL
SELECT
2,'1','10','2','00',100,980.66
UNION ALL
SELECT
3,'1','10','3','00',100,980.66
UNION ALL
SELECT
4,'1','10','4','00',100,980.66
UNION ALL
SELECT
5,'1','10','5','00',100,980.66
UNION ALL
SELECT
6,'1','10','6','00',100,980.66
UNION ALL
SELECT
7,'1','10','7','00',100,980.66
UNION ALL
SELECT
8,'1','10','8','00',100,980.66
UNION ALL
SELECT
9,'1','10','9','00',100,980.66
UNION ALL
SELECT
10,'1','10','10','00',100,980.66
UNION ALL
SELECT
11,'1','10','11','00',100,980.66
UNION ALL
SELECT
12,'1','10','12','00',100,980.66
SELECT
[JAN],[FEB],[MAR],[APR],[MAY],[JUN],[JUL],[AUG],[SEP],[OCT],[NOV],[DEC]
FROM
(
SELECT ...
January 27, 2010 at 6:49 am
DECLARE @table TABLE
(
RowNum INT , Name VARCHAR(100), SomeValue VARCHAR(100)
)
INSERT INTO @table
SELECT...
January 27, 2010 at 6:36 am
DECLARE @table table
(
IDVARCHAR(100),
ZIPINT
)
INSERT INTO @table
SELECT
'AI1', 40001
UNION ALL
SELECT
'AI1', 40002
UNION ALL
SELECT
'AI1' ,40003
UNION ALL
SELECT
'AI1' ,40004
UNION ALL
SELECT
'AI1', 40005
UNION ALL
SELECT
'AI1', 40006
UNION ALL
SELECT
'AI2', 41001
UNION ALL
SELECT
'AI2', 41002
UNION ALL
SELECT
'AI2', 41003
UNION ALL
SELECT
'AI2', 41004
UNION ALL
SELECT
'AI2', 41005
UNION ALL
SELECT
'AI2', 41006
UNION ALL
SELECT
'AI3',...
January 27, 2010 at 4:11 am
DECLARE @agegrp TABLE
(
AGE INT
)
insert into @agegrp values (0);
insert into @agegrp values (75);
insert into @agegrp values (100);
insert into @agegrp values (5);
insert into @agegrp values (18);
insert...
January 19, 2010 at 8:40 am
Viewing 15 posts - 61 through 75 (of 89 total)