Copy&Create tables. (1 Viewer)

accessman2

Registered User.
Local time
Yesterday, 20:41
Joined
Sep 15, 2005
Messages
335
Hi:
I want to do the following T-SQL, but it seems not correct. Can anybody correct me?
declare @bp table
set @bp = getdate()
select * into [@bp] from [Invoice Data]

Thanks.
 

SQL_Hell

SQL Server DBA
Local time
Today, 04:41
Joined
Dec 4, 2003
Messages
1,360
Hi there

You seem to be declaring a table variable but not giving it any columns, how many columns are in table invoice data?

Are you sure you want to ue a table variable as opposed to a temporary table? Do you know the pros and cons of each?
 

WayneRyan

AWF VIP
Local time
Today, 04:41
Joined
Nov 19, 2002
Messages
7,122
am,

AFAIK, you can't use variables in the place of database names or table names.

sp_ExecuteSQL 'select * into ' + @bp + ' from [Invoice Data]'

Wayne
 

Users who are viewing this thread

Top Bottom