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 |
seyha_moth
Yak Posting Veteran
74 Posts |
Posted - 2006-12-06 : 02:19:47
|
Dear Sir or MadamI'm glad to join this forum related to sql language and I hope that I'll get the good knowledge from here.I have the problem related to select statement is thatDeclare @Str nvarchar(4000)set @Str=''Set @St=@Str+'Address,DateofBirth,'Select FullName,StudentID,Sex,@Str from tblStudentWhen I execute the above sql query,it show FullName StudentID Sex (No Column Name) seyha 7845 M Address,DateOfBirth chanta 7444 F Address,DateOfBirthBut I want to get the result FullName StudentID Sex Address DateOfBirth seyha 7845 M PP 17-04-1975 chanta 7444 F KG 25-04-1985I hope that all of u can help me,Thank u in advanceI look forward to hearing from uGood Luck and Suceed your study and work seyha moth |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2006-12-06 : 02:22:13
|
[code]Select FullName,StudentID,Sex,Address,DateofBirth from tblStudent[/code]or if you insist to use variable, use dynamic sql:[code]Set @St=@Str+'Address,DateofBirth'EXEC('Select FullName,StudentID,' + @str + ' from tblStudent')[/code]But I don't see a reason to use D-SQL.Harsh AthalyeIndia."Nothing is Impossible" |
 |
|
seyha_moth
Yak Posting Veteran
74 Posts |
Posted - 2006-12-06 : 02:36:54
|
Thank you for your reply and I solve successfully my problem with your solutionThank you very muchI hope that I can help if you have the problem I look forward to hearing from youGood Luck and Succed your work and study.Good bye!!seyha moth |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-12-06 : 10:57:41
|
<<I'm glad to join this forum related to sql language and I hope that I'll get the good knowledge from here.>>Sure. Make sure you read this fullywww.Sommarskog.se/Dynamic_sql.htmlMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|