Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select * from user
- where username = 'admin' and
- password = '12345'
- -----------------------------------------------------------------------
- create proc tes_query()
- declare
- @table nvarchar(128),
- @sql nvarchar(max),
- @brandid int;
- SET @table = 'production.products';
- SET @brandid = 9;
- SET @sql = 'select *from ' + @table +
- ' where brand_id = ' + cast(@brandid as varchar);
- exec sp_executesql @sql;
- GO
- -----------------------------------------------------------------------
- alter proc tes_query (
- @table nvarchar(128),
- @byColumn nvarchar(128)
- )
- as begin
- declare @sql nvarchar(max);
- set @sql = 'select * from ' + @table +
- ' order by ' + quotename(@byColumn);
- exec sp_executesql @sql;
- end;
- exec tes_query 'production.products; drop table tes; select * from production.products ','list_price';
- create table TES (ID int);
- select * from tes
- exec tes_query 'production.products','list_price; drop table tes';
- select QUOTENAME('list_price; drop table tes'); -- quotename buat bikin ada kurung sikunya
- select * from [production.products]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement