Solved

sql 2008 - using cast method to block results in a view

Posted on 2010-11-23
5
329 Views
Last Modified: 2012-08-13
I have f.myfield linked in a view, I have been told we must not show resuts, but I need to show the column in the view.

cast f.myfield  as NULL
cast (f.myfield as NULL)
have tried
cast (fmyfield as int) as myfield

but this does not work as myfield is a varchar, I need to convert this first.
unsure if I am using the right method here

0
Comment
Question by:Amanda Walshaw
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 10

Assisted Solution

by:Mez4343
Mez4343 earned 250 total points
ID: 34201736
Maybe this will help. Not sure how you have linked with a view since you didnt provide all code but if all you need to to 'not show result' then maybe the SELECT into a variable will do it.

DECLARE @myfield varchar(100),
@new varchar(100)
SET @myfield = 'somedata'
-- SELECT cast(@myfield as varchar) /* shows result */
SELECT @new = cast(@myfield as varchar) /* does not show result */
0
 
LVL 32

Assisted Solution

by:Ephraim Wangoya
Ephraim Wangoya earned 250 total points
ID: 34202168

try
select ' ' as myfield
0
 

Author Comment

by:Amanda Walshaw
ID: 34215462
Msg 156, Level 15, State 1, Line 22
Incorrect syntax near the keyword 'declare'.
Msg 137, Level 15, State 1, Line 22
Must declare the scalar variable "@f".
Msg 137, Level 15, State 2, Line 23
Must declare the scalar variable "@f".
getting these erorr messages f.myfield must have f. to link into the table and I am also doing a union statment with this view.
0
 

Accepted Solution

by:
Amanda Walshaw earned 0 total points
ID: 34215536
here is the view attached in its entirety minus the name changes, but this is how its put together
the field f.religion is joined to person table.
its (nvarchar(20),null)

I need to show the label name in the view but without the results.
example.txt
0
 

Author Closing Comment

by:Amanda Walshaw
ID: 34463391
got around it
0

Featured Post

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question