On Wed, Oct 17, 2012 at 4:38 PM, MB Software Solutions, LLC
<[email protected]> wrote:
> On 10/17/2012 3:51 PM, MB Software Solutions, LLC wrote:
>>
>> I insert a row into a table whose PK is a GUID that's automatically
>> generated.  How do I get that GUID value afterwards?  I thought it would
>> be SELECT @@IDENTITY but that just returns NULL and I can see on a
>> SELECT * FROM MyTABLE that it's not a null value.
>
>
>
> Got a workaround for now.  Just created a UDF to give it to me:
>
> CREATE FUNCTION Inventory.fnGetVendorKey (@VendorName varchar(50))
>     RETURNS UniqueIdentifier
> AS
> BEGIN
>     DECLARE @PK UniqueIdentifier
>
>     RETURN (
>     select v1.Id
>       from Inventory.Vendor v1
>      where v1.VendorName = @VendorName
>         )
> END
> GO
>
>
> Hate it but it allows me to do what I want with inserting sample data into
> Parent table and then adding sample rows in Child table.
>
-----------------------

>From C# there is a lot you can do in Linq.

And that UDF() is not a good idea.  You should just ask for it
straight to the @PK and then use it in the next insert statement.


-- 
Stephen Russell
Sr. Analyst
Ring Container Technology
Oakland TN

901.246-0159 cell

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/CAJidMYJO3mUSuRyb9BXpkKJE0=_a6bedqj8zne3egib6kwk...@mail.gmail.com
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to