0
假设,我有一个临时表#Temp1与说两列名称和国籍作为Varchar(50)数据类型和表中有一些记录。我从这个表(#temp1)创建另一个临时表作为#Temp2。现在我想添加另外几列到该临时表中,将PhoneNo表示为Int和Gender作为Char数据类型。我如何实现这一目标?改变动态创建表ms
Begin Tran
Create table #Temp1(
Name Varchar(50),
Nationality Varchar(50)
);
Insert Into #Temp1 (Name, Nationality) Values ('Jayaraj','Indian');
Select Identity(Int,1,1) SlNo, Name Into #Temp2
From #Temp1 Order By Nationality
-- Now the actual issue begins. I wish to alter the #Temp2 table.
-- So I try to alter the table, to add column Phone and Gender
Alter Table #Temp2
Add(
Phone Int,
Gender Char
);
Select * from #Temp2
-- Upon Executing I get this error :
/*
Msg 102, Level 15, State 1, Line 16
Incorrect syntax near '('.
*/
Rollback
感谢您的帮助..
解决了这个问题。感谢您的快速回复。 – 2015-03-25 06:06:54
NP @JayarajPS :) – 2015-03-25 06:14:20