SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Add new blank column with null/blank value
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

maya_zakry
Constraint Violating Yak Guru

Malaysia
377 Posts

Posted - 12/08/2010 :  02:15:12  Show Profile  Click to see maya_zakry's MSN Messenger address  Send maya_zakry a Yahoo! Message  Reply with Quote
Hi,
I have weird requirement to add a column without specifying the column name in view.

select usr, '', from tbluser OR
select 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
Flowing Fount of Yak Knowledge

India
1182 Posts

Posted - 12/08/2010 :  03:37:16  Show Profile  Reply with Quote
I don't know whats the purpose but you can create a view this way.

Create view TestView as
select name,id,null as [ ] from sysobjects
Go to Top of Page

webfred
Flowing Fount of Yak Knowledge

Germany
8514 Posts

Posted - 12/08/2010 :  04:12:55  Show Profile  Visit webfred's Homepage  Reply with Quote
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.
Go to Top of Page

Kristen
Test

United Kingdom
22191 Posts

Posted - 12/08/2010 :  04:20:47  Show Profile  Reply with Quote
"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.
Go to Top of Page

maya_zakry
Constraint Violating Yak Guru

Malaysia
377 Posts

Posted - 12/10/2010 :  03:04:07  Show Profile  Click to see maya_zakry's MSN Messenger address  Send maya_zakry a Yahoo! Message  Reply with Quote
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)/¯ ~~~
Go to Top of Page

Kristen
Test

United Kingdom
22191 Posts

Posted - 12/10/2010 :  03:47:11  Show Profile  Reply with Quote
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"?
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000