Scenario 4: How to get first and last record from a table/file?
Scenario 4:
How to get first and last record from a table/file?
How to achieve this in SSIS in various ways....(inlcuding any SQL quries)......?
Thanks and Regards,
Desparado.
April 18th, 2011 2:57am
Can't you Google or search this forum.... I'm getting the feeling I'm doing your homework.Please mark the post as answered if it answers your question | My SSIS Blog:
http://microsoft-ssis.blogspot.com
Free Windows Admin Tool Kit Click here and download it now
April 18th, 2011 3:01am
Can't you Google or search this forum.... I'm getting the feeling I'm doing your homework.
Please mark the post as answered if it answers your question | My SSIS Blog:
http://microsoft-ssis.blogspot.com
I'm strongly agree with you :)http://www.rad.pasfu.com
April 18th, 2011 3:04am
Couldnt find the right solution... thats why asking here...
Thanks......
Free Windows Admin Tool Kit Click here and download it now
April 20th, 2011 2:00am
For the last record you first need to know the number of records in your source. You can do that with an extra dataflow that only counts (rowcount transformation) or you can use an execute
SQL statement with a count(*) query if your source is DB.
In the second dataflow you need to add a
rownumber and then you can use a Conditional Split to filter the first and last record.
Something like:
[rownr] == 1 || [rownr] == @rowcount
Please mark the post as answered if it answers your question | My SSIS Blog:
http://microsoft-ssis.blogspot.com
April 20th, 2011 2:20am
or you can try something in SQL with the TOP statement
SELECT top 1 * FROM yourTable ORDER BY rownr asc
union all
SELECT top 1 * FROM yourTable ORDER BY rownr desc
More info about creating a rownumber in TSQL:
http://msdn.microsoft.com/en-us/library/ms186734.aspxPlease mark the post as answered if it answers your question | My SSIS Blog:
http://microsoft-ssis.blogspot.com
Free Windows Admin Tool Kit Click here and download it now
April 20th, 2011 2:32am
If there is no ID column in the table : the last row can be fetched using the below if there is a table called TEST with one column , can be extended somthing in these lines :
CREATE TABLE TEST
(
TEST NVARCHAR(100))
CREATE TABLE #TMP
(
ID INT IDENTITY(1,1),
TEST NVARCHAR(100)
)
INSERT INTO #TMP(TEST)
SELECT TEST FROM TEST
DECLARE @COUNT INT
DECLARE @INC INT = 1
SELECT @COUNT = COUNT(1) FROM TEST
WHILE ( @INC < @COUNT)
BEGIN
DELETE FROM #TMP WHERE ID = @INC
SET @INC = @INC + 1
END
SELECT test FROM #TMP
DROP TABLE #TMP
Please mark my post as an answer if I helped you to resolve the issue or vote up if I helped you.Thanks. Regards and good Wishes, Deepak.
April 20th, 2011 2:40am
ok, yes rownumber is also the option in SQL.Please mark my post as an answer if I helped you to resolve the issue or vote up if I helped you.Thanks. Regards and good Wishes, Deepak.
Free Windows Admin Tool Kit Click here and download it now
April 20th, 2011 2:42am