Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
khalik
Constraint Violating Yak Guru
443 Posts |
Posted - 2009-03-13 : 11:01:23
|
| Hi guysI have a table variable i want to use this in my BCP command. tried with #tables also does seems to work.declare @fileBox table (SysID numeric(18) Not Null,User varchar (3),ProfileID numeric (18, 0),GroupID numeric(18),BoxType int)declare @FileName varchar(100)set @FileName='c:\box.txt'declare @TableQry varchar(100)set @TableQry ='select * from @fileBox 'insert into @fileBox select * from files where Boxtype in(2,3)SET @bcpCommand = 'bcp "' + @TableQry + '" queryout "'SET @bcpCommand = @bcpCommand + @FileName + '" -w -T -x -t"`|~|`"'alos tried EXEC master..xp_cmdshell 'bcp "SELECT * FROM ' + @fileBox + ' queryout '+ @FileName + '" -w -T -x -t"|"' Please help me guys stuck========================================Project Manager who loves to code.===============Ask to your self before u ask someone |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-03-13 : 14:05:09
|
| i think the table variable will be out of scope. you can try with ##tables however if this is concurrently executed by more than 1 user, it will cause problems |
 |
|
|
khalik
Constraint Violating Yak Guru
443 Posts |
Posted - 2009-03-14 : 05:22:07
|
| I created a phiyisical table and handling it.. now its strange it gives me errorSQLState = 42S02, NativeError = 208Error = [Microsoft][SQL Native Client][SQL Server]Invalid object name 'PGCWFBoxDistributionbyUser'.SQLState = 42000, NativeError = 8180Error = [Microsoft][SQL Native Client][SQL Server]Statement(s) could not be prepared.i am runnig this by sa login and i granted all to public.. am i missing some thing========================================Project Manager who loves to code.===============Ask to your self before u ask someone |
 |
|
|
|
|
|