| Author |
Topic |
|
Clas
Starting Member
33 Posts |
Posted - 2010-03-02 : 08:55:28
|
| HiHow do I get the ' ' in sp_rename ?@tableOldName VARCHAR(300), --- input: table1.name1@NewColumnName VARCHAR(100) --- input: name2EXEC sp_RENAME @tableOldName ,@NewColumnName, 'COLUMN'Should be like this:EXEC sp_RENAME 'table1.name1' ,'name2', 'COLUMN' |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-03-02 : 09:03:38
|
| you dont need '', storing the value in varchar field is enough------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-03-02 : 09:05:05
|
| declare @sql varchar(8000)@tableOldName VARCHAR(300), --- input: table1.name1@NewColumnName VARCHAR(100) --- input: name2set @sql='sp_RENAME '''+@tableOldName+''','''+@NewColumnName+''',''COLUMN'''EXEC (@sql)MadhivananFailing to plan is Planning to fail |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-03-02 : 09:06:53
|
quote: Originally posted by madhivanan declare @sql varchar(8000)@tableOldName VARCHAR(300), --- input: table1.name1@NewColumnName VARCHAR(100) --- input: name2set @sql='sp_RENAME '''+@tableOldName+''','''+@NewColumnName+''',''COLUMN'''EXEC (@sql)MadhivananFailing to plan is Planning to fail
sorry i didnt understand whats the need of D-SQL here?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-03-02 : 09:18:44
|
Yes. No need of Dynamic SQL MadhivananFailing to plan is Planning to fail |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-03-02 : 09:31:04
|
quote: Originally posted by madhivanan Yes. No need of Dynamic SQL MadhivananFailing to plan is Planning to fail
Ok . Thought I missed something obvious ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
vaibhavktiwari83
Aged Yak Warrior
843 Posts |
Posted - 2010-03-02 : 09:35:36
|
| Still i dint get the syntax please rewrite the syntaxVabhav T |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-03-02 : 09:37:37
|
quote: Originally posted by vaibhavktiwari83 Still i dint get the syntax please rewrite the syntaxVabhav T
Whci syntax are you talking about?MadhivananFailing to plan is Planning to fail |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-03-02 : 09:38:05
|
quote: Originally posted by vaibhavktiwari83 Still i dint get the syntax please rewrite the syntaxVabhav T
syntax of what?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
vaibhavktiwari83
Aged Yak Warrior
843 Posts |
Posted - 2010-03-02 : 09:41:58
|
| SP_RenameVabhav T |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
vaibhavktiwari83
Aged Yak Warrior
843 Posts |
Posted - 2010-03-02 : 09:49:28
|
| thanksVabhav T |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-03-02 : 09:54:12
|
quote: Originally posted by vaibhavktiwari83 thanksVabhav T
welcome!------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|