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 |
|
samsekar
Constraint Violating Yak Guru
437 Posts |
Posted - 2004-07-28 : 09:23:26
|
Hi I am trying to update the column if that column exists in the table. This table is generated dynamically. I have wrote stored procedure something like this, but it gives Invalid column name at runtime. Any help is highly appreciated !!IF EXISTS (Select * from syscolumns where [name] = 'tag' and [id] = object_id('tableA'))BEGINUPDATE A SET A.tag = B.tagFROM tableA A JOIN tableB B ON A.id = B.idEND- Sekar |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2004-07-28 : 09:40:04
|
| ??? Why would you even try to do this?MeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
samsekar
Constraint Violating Yak Guru
437 Posts |
Posted - 2004-07-28 : 09:44:58
|
| The table is generated dynamically, the generated table might have the column based on the input given for table creation. In the stored procedure, if the column exists i need to update the data. Can someone throw some lights on thisInfact I am trying to do without using Dynamic SQL- Sekar |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2004-07-28 : 10:03:40
|
| Have SProc_A and SProc_B - one which does the extra column, and one which doesn't - and EXEC which ever is appropriate??Kristen |
 |
|
|
samsekar
Constraint Violating Yak Guru
437 Posts |
Posted - 2004-07-28 : 10:08:46
|
| Thanks Kristen, Even I thought the same, infact there are some 5-6 columns which gets updated from different tables. And I dont want to have 6-7 stored procedures, any other thoughts!!.- Sekar |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2004-07-28 : 10:11:47
|
| What are these columns for? User Defined fields, or something like that?Kristen |
 |
|
|
|
|
|