Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

Incremental Number Expand / Collapse
Author
Message
Posted Friday, November 30, 2012 3:12 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 6:30 AM
Points: 13,083, Visits: 12,548
sasansamani (11/30/2012)
SELECT DMax("[AssetNumber]","Waste Hauler Number","+1") AS Expr1 FROM [Waste Hauler Number];

I am getting two 4001. What I am doing incorrectly?


The last parameter is the criteria (it acts like a where clause). "+1" is not valid there.

Personally I hate those built in functions. I find them obtuse and difficult to read.

I would write that as a query instead.

select MAX(AssetNumber) + 1 from [Waste Hauler Number]



_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1391572
Posted Friday, November 30, 2012 3:20 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, January 11, 2013 11:52 AM
Points: 28, Visits: 50
thank you very much. It works now.

I tried to use something simlar to that.
Post #1391574
Posted Friday, November 30, 2012 3:30 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 6:30 AM
Points: 13,083, Visits: 12,548
You're welcome. Glad that worked for you.

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1391577
Posted Saturday, December 1, 2012 3:30 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Monday, July 21, 2014 4:34 PM
Points: 48, Visits: 9,470
Hi

My apologies for not being able to contribute to this earlier - I'm fairly certainthat I am in a different time zone to you.

If you are wanting to do this in an Access query, then you could use a LEFT OUTER join. Join the table with the incrementing number to the table you wish to check via the two number attributes, then set the join type to the left outer join option (2).

If you create a test query in this way (Important Note: drag your join from the table with the incrementing number to the table you wish to check) and simply add the two attribute, you will see matching numbers where you have used the number and the incrementing number and a null in the cases where the numbers haven't been used.

Taking this a step further, add a null criteria for the attribute in the table you are checking, and you will be returned a set of numbers that haven't been used. You could then use this as a subquery for generating the next unused number by changing the query to a group (aggreagte) query and use the min option.

Cheers

Rowan
Post #1391638
Posted Saturday, December 1, 2012 4:01 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, January 11, 2013 11:52 AM
Points: 28, Visits: 50
thank you everyone
Post #1391675
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse