Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Returning newid(()
Message
De
30/12/2014 08:50:50
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
 
 
À
30/12/2014 08:44:54
Mike Yearwood
Toronto, Ontario, Canada
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Versions des environnements
SQL Server:
SQL Server 2012
Application:
Desktop
Divers
Thread ID:
01612793
Message ID:
01612831
Vues:
46
>>>>Hi Naomi,
>>>>That makes sense and I will give that a test run. I want to return the entire row back.
>>>>I appreciate it.
>>>
>>>Hi, Tim,
>>>
>>>Naomi's reply is exactly what you need, I just wanted to jump in with 2 more things.
>>>
>>>First, the OUTPUT statement has an optional OUTPUT INTO capability. So if you want to redirect the results of your insert (with the newly generated GUIDs and any other derived/calculated columns) to any table (including a temp table), you can. (The table has to exist...OUTPUT INTO won't create a new table on the fly for you)
>>>
>>>Second, just curious, since you're using SQL 2012 (which has the new Sequence Object). What's the reason for using a GUID? I realize it's a loaded question, just curious if the requirements call for it.
>>>
>>>Thanks...
>>
>>Thanks Kevin,
>>
>>I changed to use the OUTPUT statement yesterday and it worked great. I did notice the OUTPUT INTO and that would work great for situations where I need to do something with the row within the procedure, but I just wanted to return the new row.
>>
>>We are using uniqueidentifiers so we can replicate across databases. I am not familiar with the new Sequence Object, but I will be after today. :-)
>>Thanks
>
>I think you'll find the NewSequentialID() is better than NewID() in terms of inserting performance.

Yes you are correct and in terms of index performance.
Thanks
Timothy Bryan
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform