| |

VerySource

 Forgot password?
 Register
Search
View: 949|Reply: 5

!!!!!! Why can't dynamic SQL statements execute ????

[Copy link]

2

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-3-17 14:00:01
| Show all posts |Read mode
declare @ g_Condi2 varchar (1000)
set @ g_Condi2 = 'and State = `` On the Job' ''
select name, sex, address, photo, state from t_name
where name = '张三' + @ G_Condi2


Why can't it be executed? What should be done?
Reply

Use magic Report

0

Threads

14

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-6-19 17:30:01
| Show all posts
declare @g_Condi2 varchar(1000)
set @g_Condi2 ='and State = ``Incumbent'''
exec('select name,sex,address,photo,state from t_name
where name=``Zhang San'''+@G_Condi2+'');
Reply

Use magic Report

0

Threads

53

Posts

29.00

Credits

Newbie

Rank: 1

Credits
29.00

 China

Post time: 2020-6-23 15:45:01
| Show all posts
Agree upstairs
Reply

Use magic Report

2

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-7-7 13:45:01
| Show all posts
I also do this withabomination, but it is called through a stored procedure and cannot return the query result set to the caller.
Reply

Use magic Report

0

Threads

12

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-7-9 15:30:01
| Show all posts
declare @g_Condi2 varchar(1000)
set @g_Condi2 ='and State = ``Incumbent'''
create table #test
(name varchar(10),
sex bit,
address varchar(100),
photo image,
state bit
)

insert into #test
exec('select name,sex,address,photo,state from t_name
where name=``Zhang San'''+@G_Condi2+'');

select * from #test
Reply

Use magic Report

2

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-7-14 10:45:02
| Show all posts
Did not get the desired answer.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list