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 |
|
ero-sennin26
Starting Member
7 Posts |
Posted - 2007-07-05 : 11:37:18
|
| Good Day guys, sorry i'm just new in SQL Server.My problem is like this:I want to pass Table Object to a declared variable and make View.Usually we make like this:"Select * from Table1"I want like this:"Select * from @Table1"I want to pass Table1 to a variable "@Table1" which the variablereads as Table.Please help me guys, i really appriciated everything.Thanks,Ero-Sennin26 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-07-05 : 11:39:11
|
| [code]Declare @sql varchar(8000)Set @sql = 'Select * from ' + @Table1Exec(@sql)[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
ero-sennin26
Starting Member
7 Posts |
Posted - 2007-07-05 : 11:52:06
|
| Mr. Harsh Athalye,It works, thank you very much.I hope i'll be professional like you someday.Thanks again.Regards,Ero-Sennin26 |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-07-05 : 11:55:53
|
| Also make sure you read this fullywww.sommarskog.se/dynamic_sql.htmlMadhivananFailing to plan is Planning to fail |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-07-05 : 11:57:32
|
Madhi,I bet myself that you are going to post that link! Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-07-05 : 12:06:50
|
quote: Originally posted by harsh_athalye Madhi,I bet myself that you are going to post that link! Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED"
I didnt want to disappoint you MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|