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 |
maya_zakry
Constraint Violating Yak Guru
379 Posts |
Posted - 2010-12-08 : 02:15:12
|
Hi,I have weird requirement to add a column without specifying the column name in view.select usr, '', from tbluser ORselect usr, '' AS ' ' from tblusr it's fine with normal query, but when i put in view, it cannot work with error : Create View or Function failed because no column name was specified for column 6.~~~who controls the past controls the future, who controls the present controls the past. ¯\(º_o)/¯ ~~~ |
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-12-08 : 03:37:16
|
I don't know whats the purpose but you can create a view this way.Create view TestView asselect name,id,null as [ ] from sysobjects |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-12-08 : 04:12:55
|
You should not have that garbage in your view!Create an empty column where you need it in your application but not in your view. No, you're never too old to Yak'n'Roll if you're too young to die. |
|
|
Kristen
Test
22859 Posts |
Posted - 2010-12-08 : 04:20:47
|
"You should not have that garbage in your view!"But you don't know what the application is ...Maybe the "application" is a user selecting from a VIEW directly into Excel ... in which case the Column Headings in the spreadsheet will start out as they come from the view - and it may be desirable that the users don't have to go in and fix them up every time they make a new spreadsheet query. |
|
|
maya_zakry
Constraint Violating Yak Guru
379 Posts |
Posted - 2010-12-10 : 03:04:07
|
thx pk_bohra. but actually i need multiple blank column, so since we name the 1st one as [ ], the next blank column result in column unique error.yes, kristen are right, it's for excel purpose afetr user import.~~~who controls the past controls the future, who controls the present controls the past. ¯\(º_o)/¯ ~~~ |
|
|
Kristen
Test
22859 Posts |
Posted - 2010-12-10 : 03:47:11
|
Well - you could use multiple spaces, but I don't know whether that you be acceptable or not?Actually ... turns out you can't, I just tried it, multiple spaces are treated as two spaces by the looks of it.Can you have column names [*], [#], [.] etc. as being "fairly bland"? |
|
|
|
|
|
|
|