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 |
|
tocroi72
Yak Posting Veteran
89 Posts |
Posted - 2004-09-20 : 10:23:24
|
| Hi allI have this script:Declare @Var int, @sql nvarchar(2000),@column nvarchar(100)Set @var = 1While @Var <= 32begin set @column = 'day' + convert(varchar,@var) SET @sql = 'INSERT INTO Master SELECT YandMColumn,' + convert(varchar,@var) + ',' + @Column + ' From High' Execute @sql set @var = @var + 1--print @sqlEndWHen i run the script, it returns me this erro message belowCould not find stored procedure 'INSERT INTO Master SELECT YearColumn,1,day1 From High'.I have a table of data for a year like thisYandMColumn|Day1|day2|day3.....Day31|1996/01 12 32 431996/02 14 31 56and I want to create a table look like thisYandMColumn|Day|Amount1996/01 1 121996/01 2 321996/01 3 431996/02 1 141996/02 2 311996/02 3 56Thanks |
|
|
raymondpeacock
Constraint Violating Yak Guru
367 Posts |
Posted - 2004-09-20 : 10:30:26
|
| Put brackets around the variable used in your exec.EXEC (@sql)Raymond |
 |
|
|
tocroi72
Yak Posting Veteran
89 Posts |
Posted - 2004-09-20 : 10:46:18
|
| Thanks! i totally forgot that. |
 |
|
|
|
|
|