Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. create table SomeTable
  2. (
  3. id uniqueidentifier default newsequentialid(),
  4. foo text
  5. )
  6.  
  7. insert into SomeTable (foo)
  8. output inserted.id
  9. values ('bar')
  10.  
  11. using (var conn = new SqlConnection(@"..."))
  12. using (var cmd = conn.CreateCommand())
  13. {
  14. cmd.CommandText = "insert into SomeTable (foo) output inserted.id values ('bar')";
  15. conn.Open();
  16. var guid = (Guid)cmd.ExecuteScalar();
  17. Console.WriteLine(guid);
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement