| |

VerySource

 Forgot password?
 Register
Search
View: 1128|Reply: 8

Simple temporary table problem

[Copy link]

2

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-9 16:40:01
| Show all posts |Read mode
I use:
declare @t table (S_DATA int, S_TIME int, S_ID int)
select * into @t from text_one

instead:
insert @t
select 3, 12, null union all
select 2, 13, null union all
select 2, 14, null union all

Tip: There is an error near "@t", please solve it for me ~ Thank you
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-22 14:00:01
| Show all posts
Don’t do the first sentence: declare @t table(S_DATA int,S_TIME int,S_ID int) try
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-22 21:00:01
| Show all posts
select can not directly use variables as queries, use dynamic statements
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-22 21:30:01
| Show all posts
A simple SQL common sense, if the table exists, you cannot select into, you must insert into. Since the table variable must be declared before it is used, then you cannot select into.
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-22 21:45:02
| Show all posts
Try lz
declare @t table(S_DATA int,S_TIME int,S_ID int)
insert into @a
select * from text_one
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-22 22:00:01
| Show all posts
declare @t table(S_DATA int, S_TIME int, S_ID int) is useless
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-22 22:15:01
| Show all posts
pupityV
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-22 22:45:01
| Show all posts
pupitypunctuality
Do good things for the people! ! ! ! ! ! ! ! ! ! ! ! ! !
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-22 23:00:01
| Show all posts
I am also a novice and I have learned one more, so it is correct to sayshijie428.

Learn! ! !
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