Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Generate a MAc adress with a stored procedure

Generate a MAc adress with a stored procedure

Scheduled Pinned Locked Moved Database
databasequestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bluepoison
    wrote on last edited by
    #1

    Hi all, I would like to generate MAC addresses between a certain range in a stored procedure. The MAC addresses needed to be stored in a table. Any ideas? Suggestions?:thumbsup: I need something like below DECLARE @Max_MAC BINARY(8) DECLARE @StartRange BINARY(8) DECLARE @EndRange BINARY(8) DECLARE @MAC_Address BINARY(8) SET @StartRange = 0x00000004A500114B SET @EndRange = 0x00000004A50F11FF SELECT @Max_MAC = MAX(MAC_Address) FROM MAC_Address IF (@Max_Mac >= @StartRange and @Max_Mac < @EndRange) begin @Max_Mac = generate a higher macaddress INSERT INTO MAC_Address(MAC_Address,Timestamp) VALUES (@MAX_MAC, getdate()) END I do not know how I can count a number more to the MAcAdress I would like to become to a table with macadresses like 0x00000004A500114B 0x00000004A500114C 0x00000004A500114D ... Thanks in advance Tom Denys

    A L 2 Replies Last reply
    0
    • B bluepoison

      Hi all, I would like to generate MAC addresses between a certain range in a stored procedure. The MAC addresses needed to be stored in a table. Any ideas? Suggestions?:thumbsup: I need something like below DECLARE @Max_MAC BINARY(8) DECLARE @StartRange BINARY(8) DECLARE @EndRange BINARY(8) DECLARE @MAC_Address BINARY(8) SET @StartRange = 0x00000004A500114B SET @EndRange = 0x00000004A50F11FF SELECT @Max_MAC = MAX(MAC_Address) FROM MAC_Address IF (@Max_Mac >= @StartRange and @Max_Mac < @EndRange) begin @Max_Mac = generate a higher macaddress INSERT INTO MAC_Address(MAC_Address,Timestamp) VALUES (@MAX_MAC, getdate()) END I do not know how I can count a number more to the MAcAdress I would like to become to a table with macadresses like 0x00000004A500114B 0x00000004A500114C 0x00000004A500114D ... Thanks in advance Tom Denys

      A Offline
      A Offline
      Abhishek Sur
      wrote on last edited by
      #2

      :wtf: Mac address is the primary address of a Network Interface that uniquely identifies a PC. why you need to generate MAC Addresses ? If you need to generate unique id why not you use GUID s ... :confused:

      Abhishek Sur


      My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

      **Don't forget to click "Good Answer" if you like to.

      B 1 Reply Last reply
      0
      • B bluepoison

        Hi all, I would like to generate MAC addresses between a certain range in a stored procedure. The MAC addresses needed to be stored in a table. Any ideas? Suggestions?:thumbsup: I need something like below DECLARE @Max_MAC BINARY(8) DECLARE @StartRange BINARY(8) DECLARE @EndRange BINARY(8) DECLARE @MAC_Address BINARY(8) SET @StartRange = 0x00000004A500114B SET @EndRange = 0x00000004A50F11FF SELECT @Max_MAC = MAX(MAC_Address) FROM MAC_Address IF (@Max_Mac >= @StartRange and @Max_Mac < @EndRange) begin @Max_Mac = generate a higher macaddress INSERT INTO MAC_Address(MAC_Address,Timestamp) VALUES (@MAX_MAC, getdate()) END I do not know how I can count a number more to the MAcAdress I would like to become to a table with macadresses like 0x00000004A500114B 0x00000004A500114C 0x00000004A500114D ... Thanks in advance Tom Denys

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        Hi, Mac addresses are 8-byte (unsigned) numbers that typically get shown in hex with or without dashes in between bytes. You could hold their numeric value in a System.UInt64 (for .NET programming languages), show them with ToString("X16"), and handle them as NUMERIC in SQL according to this[^]. I think that beats the alternative of handling them as strings, since then you would have to implement some code to "hex increment" a string... BTW: I would rather not have to store a range of MAC addresses, unless I were a manufacturer of network equipment that is. :)

        Luc Pattyn


        Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.


        Local announcement (Antwerp region): Lange Wapper? Neen!


        1 Reply Last reply
        0
        • A Abhishek Sur

          :wtf: Mac address is the primary address of a Network Interface that uniquely identifies a PC. why you need to generate MAC Addresses ? If you need to generate unique id why not you use GUID s ... :confused:

          Abhishek Sur


          My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB

          **Don't forget to click "Good Answer" if you like to.

          B Offline
          B Offline
          bluepoison
          wrote on last edited by
          #4

          I need to generate Mac address because we Program a Mac address in different kind of PCB's (like network cards) We want to trace the Mac address that we program in the PCB's. We get difefrent ranges that we use for that.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups