Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

copying existing database table

Status
Not open for further replies.

Mingas

Programmer
Jul 10, 2013
15
0
0
ZA
Guys please help I'm losing it. I'm trying to copy or backup my existing db table at button click using an sql query in visual studio 2010 C#. I keep getting the same error and batle to figure out what the fault could be.

#######I first tried....

string sqldatex = "Select * Into NewTable From OldTable";
SqlCommand comdatex = new SqlCommand(sqldatex, conn);
comdatex.ExecuteScalar();

Error: Incorrect syntax near 'NewTable'.


###########And then I tried...

string sqldatex = "INSERT INTO NewTable (SLA) SELECT SLA FROM OldTable";
SqlCommand comdatex = new SqlCommand(sqldatex, conn);
comdatex.ExecuteScalar();

Error: Incorrect syntax near 'NewTable'.



Please help me
 
Thank you all...i figured it out.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top