Advertisement
Guest User

Untitled

a guest
Apr 29th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. select * from user
  2. where username = 'admin' and
  3. password = '12345'
  4.  
  5. -----------------------------------------------------------------------
  6. create proc tes_query()
  7. declare
  8. @table nvarchar(128),
  9. @sql nvarchar(max),
  10. @brandid int;
  11.  
  12.  
  13. SET @table = 'production.products';
  14. SET @brandid = 9;
  15. SET @sql = 'select *from ' + @table +
  16. ' where brand_id = ' + cast(@brandid as varchar);
  17. exec sp_executesql @sql;
  18.  
  19. GO
  20. -----------------------------------------------------------------------
  21.  
  22. alter proc tes_query (
  23. @table nvarchar(128),
  24. @byColumn nvarchar(128)
  25. )
  26. as begin
  27. declare @sql nvarchar(max);
  28. set @sql = 'select * from ' + @table +
  29. ' order by ' + quotename(@byColumn);
  30. exec sp_executesql @sql;
  31. end;
  32.  
  33. exec tes_query 'production.products; drop table tes; select * from production.products ','list_price';
  34.  
  35. create table TES (ID int);
  36.  
  37. select * from tes
  38.  
  39. exec tes_query 'production.products','list_price; drop table tes';
  40.  
  41. select QUOTENAME('list_price; drop table tes'); -- quotename buat bikin ada kurung sikunya
  42.  
  43. select * from [production.products]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement