Ticket sales

xiaoxiao2021-03-06  133

--1.Declare @ var1 varchar (20) set @ var1 = 'White'select * from authors where au_lname = @ var1

--2.Declare @ var1 varchar (20) set @ var 1 = 'White'Declare @S nvarchar (4000) set @ s =' select * from authors where au_lname = @ var1'exec sp_executesql @ s, n '@ varchar1 varchar (20) ', @ var1go

--3. Test Declare @ var1 varchar (20) set @ var1 = 'White'Declare @ var2 varchar (20) DECLARE @S nvarchar (4000) set @ s =' select ' cast (@ var2 as varchar) '= au_lname from authors where au_lname = @ var1'exec sp_executesql @ s, n' @ var1 varchar (20), @ var2 varchar (20) ', @ var1, @ var2select @ var2print @ var2go

/ * CREATE PROC QueryHose @ Employee_ID VARCHAR (5), @ Top Intas Declare @S nvarchar (4000) Set @ s = 'SELECT TOP' CAST (@top as varchar) '* - Less * from house_contract join house_state on house_contract.house_id = house_state.house_idwhere employee_id = @ employee_id and whether_rent = '' 0 '' 'exec sp_executesql @ s, N' @ employee_id varchar (5) ', @ employee_idgo

* / - 4. Test

CREATE PROCEDURE dbo.GetTimeStamp@PAT0000 int, @ ts1 timestamp output, @ tablename nvarchar (10) ASdeclare @sql nvarchar (500) set @ sql = N'Select @ ts1 = TS From ' @ tableName ' where PAT0000 = ' Convert (nvarchar, @ pat0000) execute sp_executesql @ SQL, N '@ Ts1 TimeStamp Output', @ TS1 OUTPUT

转载请注明原文地址:https://www.9cbs.com/read-127886.html

New Post(0)