Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2010-11-23
5
Medium Priority
?
331 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 1000 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 1000 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

There have been several questions about Large Transaction Log Files in SQL Server 2008, and how to get rid of them when disk space has become critical. This article will explain how to disable full recovery and implement simple recovery that carries…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

721 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