Solved

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

Posted on 2010-11-23
5
324 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
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:ewangoya
ewangoya 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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

After restoring a Microsoft SQL Server database (.bak) from backup or attaching .mdf file, you may run into "Error '15023' User or role already exists in the current database" when you use the "User Mapping" SQL Management Studio functionality to al…
Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

914 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

20 Experts available now in Live!

Get 1:1 Help Now