Solved

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

Posted on 2010-11-23
5
328 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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

733 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