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. Web Development
  3. Can I get the value of newid() function of SQLserver2k from ASP

Can I get the value of newid() function of SQLserver2k from ASP

Scheduled Pinned Locked Moved Web Development
helptutoriallearning
2 Posts 2 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.
  • _ Offline
    _ Offline
    _skidrow_vn_
    wrote on last edited by
    #1

    ASP & SQLserver2k & Windows2003 I use ASP to add data to 2 tables I have 2 tables: Invoice and InvoiceDetail Invoice contains: InvoiceID, ClientName, InvoiceDate........ InvoiveDetail contains: InvoiceID, Name,Price,Quantity.... I set default of InvoiceID(Invoice table)=newid() so I dont need to insert a new value when I add a new record but I can not get value of newid() Example: Invoice for Client "Tom" I use "INSERT Invoice (ClientName, InvoiceDate) VALUES ('Tom','30/1/2004')" and SQLserver2k auto create a value for InvoiceID such as {BB10687B-87F7-44E4-9397-8D510BBDFA9C} and then ..... I WANT TO GET {BB10687B-87F7-44E4-9397-8D510BBDFA9C} I NEED IT to add detail of this invoice for InvoiceDetail table like: InvoiceID - Name - Price - Quantity {BB10687B-87F7-44E4-9397-8D510BBDFA9C} - book - 26.5$ - 5 {BB10687B-87F7-44E4-9397-8D510BBDFA9C} - CD - 700.95$ - 1 I think 1) SELECT InvoiceID FROM Invoice WHERE ClientName='Tom' AND InvoiceDate='30/1/2004'" but this is not good, may be duplicate all value in all column 2) May I have to add a new column in table 3) I have to calculate my InvoiceID and not use newid() function of SQLsrv2k :(( Please help me to get value of newid() function in SQLserver2k thanks alot

    L 1 Reply Last reply
    0
    • _ _skidrow_vn_

      ASP & SQLserver2k & Windows2003 I use ASP to add data to 2 tables I have 2 tables: Invoice and InvoiceDetail Invoice contains: InvoiceID, ClientName, InvoiceDate........ InvoiveDetail contains: InvoiceID, Name,Price,Quantity.... I set default of InvoiceID(Invoice table)=newid() so I dont need to insert a new value when I add a new record but I can not get value of newid() Example: Invoice for Client "Tom" I use "INSERT Invoice (ClientName, InvoiceDate) VALUES ('Tom','30/1/2004')" and SQLserver2k auto create a value for InvoiceID such as {BB10687B-87F7-44E4-9397-8D510BBDFA9C} and then ..... I WANT TO GET {BB10687B-87F7-44E4-9397-8D510BBDFA9C} I NEED IT to add detail of this invoice for InvoiceDetail table like: InvoiceID - Name - Price - Quantity {BB10687B-87F7-44E4-9397-8D510BBDFA9C} - book - 26.5$ - 5 {BB10687B-87F7-44E4-9397-8D510BBDFA9C} - CD - 700.95$ - 1 I think 1) SELECT InvoiceID FROM Invoice WHERE ClientName='Tom' AND InvoiceDate='30/1/2004'" but this is not good, may be duplicate all value in all column 2) May I have to add a new column in table 3) I have to calculate my InvoiceID and not use newid() function of SQLsrv2k :(( Please help me to get value of newid() function in SQLserver2k thanks alot

      L Offline
      L Offline
      l a u r e n
      wrote on last edited by
      #2

      u should be using an auto-increment column as the primary key and using @@INSERT_ID (or something) to get the value between sql statements maybe u should be doing this inside a transaction too ;)


      "there is no spoon"
      biz stuff   about me

      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