Solved

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

Posted on 2010-11-23
5
323 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
  • 3
5 Comments
 
LVL 10

Assisted Solution

by:Mez4343
Mez4343 earned 250 total points
Comment Utility
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:ewangoya
ewangoya earned 250 total points
Comment Utility

try
select ' ' as myfield
0
 

Author Comment

by:Amanda Walshaw
Comment Utility
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
Comment Utility
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
Comment Utility
got around it
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
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 seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now