| |

VerySource

 Forgot password?
 Register
Search
View: 11|Reply: 4

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

[Copy link]

2

Threads

3

Posts

4

Credits

Newbie

Rank: 1

Credits
4

 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

9

Posts

7

Credits

Newbie

Rank: 1

Credits
7

 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

46

Posts

25

Credits

Newbie

Rank: 1

Credits
25

 China

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

Use magic Report

2

Threads

3

Posts

4

Credits

Newbie

Rank: 1

Credits
4

 China

 Author| Post time: 3 day(s) ago
| 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

10

Posts

7

Credits

Newbie

Rank: 1

Credits
7

 China

Post time: Yesterday 15:30
| 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

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

Points Rules

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

Quick Reply To Top Return to the list