Your text file '\\pcnamed\TS_Call_Output.txt' probably has duplicate values for the primary key, hence you are getting the error.
View the text file and remove any primary key duplicates.
Try something along the following lines:
DECLARE @tmptable TABLE (CID VARCHAR(30), ROWNO INT, internal_container_num VARCHAR(30))
INSERT INTO @tmptable
select s.container_id, ROW_NUMBER() OVER ( partition by s.container_id order by s.container_id) AS ROW_NUMBER, internal_container_num...
Try this:
SELECT n.doc, ISNULL(a.pendinfo1,0) AS pendinfo1, ISNULL(pendinfo2,0) AS pendinfo2
FROM natdocfile n
LEFT OUTER JOIN
(SELECT t.fo, ISNULL(COUNT(t.cossn), 0)AS pendinfo1
FROM t16pendall t
WHERE (mft_POSN1_CD in('b','d') or (MFT_POSN1_CD='a' and aged_alien_rsw='y'))...
When area is less than 10 (i.e. 0-9), then output with a preceding 0. For example, if area = 4, then output '04'.
Otherwise, output area as two characters (e.g. if area=25, it will output '25').
This assumes that area will be 0 through 99.
If it is greater than two digits, results will be...
If you are using SQL Server 2005 or 2008, then you can easily do this by using the RANK function as shown below:
SELECT tmp.Account, tmp.Branch FROM
(SELECT Account, Branch, RANK() OVER (Partition by Account ORDER BY Branch) as Rank
FROM AccountBranch
) tmp
WHERE tmp.Rank = 1
Explanation...
It looks like there are some rows in your table that do not conform to the 22/11/2008 00:00:00 format. Hence, the error is generated.
To verify if that is the problem, try to put a TOP statement to select, say 2 rows, and verify if that works.
For example,
select TOP 2
CASE [Column 6]...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.