Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. declare @custid1 char (6), @CustName1 nvarchar(255)
  2. set @custid1 = 001
  3. set @custName1 = 'Pete'
  4. select @custid1 = 'c102', @custName1 = 'Pete'
  5.  
  6. update CustomerRecord
  7. set CustomerID = @custid1
  8. where CustName = @CustName1
  9.  
  10. select * from CustomerRecord where CustomerID = @custid1
  11. if @@ROWCOUNT = 0
  12. print 'The id ' + cast(@custid1 as varchar(5)) + ' does not exists'
  13. else
  14. print 'Update successsful'
  15.  
  16. go
  17. alter procedure CustOrder1
  18. @custid1 CHAR (6), @custName1 VARCHAR (40), @SalesOrderID CHAR (10)
  19. as
  20. begin
  21. if not exists (select * from CustomerRecord
  22. where CustName = @CustName1)
  23. begin
  24. insert into CustomerRecord (CustomerID)
  25. values (@custid1)
  26. end
  27. end
  28. go
  29.  
  30. exec CustOrder1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement