Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing GUID from Sql server 2000 to VB?

Status
Not open for further replies.

yakata

Programmer
Dec 13, 2000
30
0
0
FR
Hi to all,
I'm using a stored proc to insert recs into table in SQL 2000. One column of the table is Uniqueidentifier and rowguide. When i insert, it creates a GUID value in that field.

Now I want to have this Guid available to insert it in a new line in another table.

I use @@identity in return value of my stored proc but it always returns '0', even if the Guid is correctly created...(
Any idea ?

TIA !-)

Yak
 
The @@Identity is for identity columns, not GUID columns. To return it to your VB program your Stored Procedure must return it as part of a Select statement, or as an "OUT" parameter.

Chip H.
 
Hi, Chip,
And thanks for the idea :)
But well, do an insert followed by a select to have the last Guid inserted is what i tries not to do...
But if there is no other way, well .-(

By the way, what do you mean in an 'out' parameter ?

TIA for a reply

Yak

 
You can declare a stored procedure parameter as an output parameter. Search under "Returning Data Using OUTPUT Parameters" in books online. You can also search on "Using Return Code and Output Parameters for Stored Procedures" in MSDN (this is actually a little better).

Chip H.
 
Hello, Chip,

You deserve a nice day !-)
Done what you suggest, works fine, great help !

Thanks

Yak
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top