Showing posts with label integer. Show all posts
Showing posts with label integer. Show all posts

Wednesday, March 21, 2012

Row number in the dataflow task

Hello all,

I got a text file with two columns. and I need to generate a integer key automatically with the row number (or any distinct number, I thought row number will be OK). and when I make the data flow task to import this text file into a raw file I need to get the unique rownumber as Id.
How can I make this in the data flow tak?

regards,

This should work for you:

http://www.ssistalk.com/2007/02/20/generating-surrogate-keys/

|||

Did you try searching the forum? That question has been asked before and several are the ways of doing it:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=379124&SiteID=1

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1533040&SiteID=1

|||

Thank you.....

I am so happy with the script componant......

It works good.....

Thank you again.

Regards

Saturday, February 25, 2012

Round Up to next integer

Is there a way to round up a value to the next integer?

For example 2.1 needs to be 3 and 4.9 need to be 5.

use ceiling

SELECT CEILING(2.1) AS CeilsTo3, CEILING(4.9) AS CeilsTo5|||Thanks.

round up

X is a float and I need to perform x/10 and round the result up to the integer. So if result is 0.4 -> 1, if 1.1 -> 2.

How can I do this with SQL?

? Use the CIELING function: SELECT CIELING(x/10) FROM YourTable -- Adam MachanicPro SQL Server 2005, available nowhttp://www..apress.com/book/bookDisplay.html?bID=457-- <JIM.H.@.discussions.microsoft.com> wrote in message news:4165a8e6-3d64-4db1-9c4b-1cec7040f35a@.discussions.microsoft.com... X is a float and I need to perform x/10 and round the result up to the integer. So if result is 0.4 -> 1, if 1.1 -> 2. How can I do this with SQL?|||

use CEILING

select ceiling(0.4),ceiling(1.1)

Denis the SQL Menace

http://sqlservercode.blogspot.com/

|||

you can use the round function

For Example:

SELECT round(4.9, 0)

Check out BOL for more details

AWAL

|||

Not really, OP wanted 2 for 1.1

round gives 1

Denis the SQL Menace

http://sqlservercode.blogspot.com/

round up

X is a float and I need to perform x/10 and round the result up to the integer. So if result is 0.4 -> 1, if 1.1 -> 2.

How can I do this with SQL?

SELECTCEILING(X/10)AS numRoundup

FROM yourTable

round a value to the nearest integer

how do i round a value to the nearest integer?

Quote:

Originally Posted by poopsy

how do i round a value to the nearest integer?


Make use of ROUND()
Check here for detail