Testing If Value Is Null

Mar 31, 2008

Hi,

How do I write a query where if a column, "value," is NULL I return
the phrase "No value entered" but otherwise return the column's value,
even if it is the empty string? I'm tried to modify this simple query

SELECT value FROM meta_data

Thanks, - Dave

View 2 Replies


ADVERTISEMENT

Testing For Null In Crosstab

Jan 27, 2005

I'm sure that I'm being stupid but this is driving me nuts. The case statements in the following query always return the ELSE and never return the THEN for the NULL.

Code:

select day(ums_users.created), count(*) as Total,
SUM(CASE ums_user_info.info_key WHEN NULL THEN 1 ELSE 0 END) AS UnReg,
SUM(CASE ums_user_info.info_key WHEN NULL THEN 0 ELSE 1 END) AS Reg
from ums_users
left join ums_user_map
on ums_users.user_id = ums_user_map.user_id
left join ums_groups
on ums_user_map.group_id = ums_groups.group_id
left join ums_user_info
on ums_user_info.user_id = ums_users.user_id

where (ums_groups.group_id = '43A73FAE-0C2C-4ED8-BE1E-B32C12DB163D'
or ums_groups.group_parent_id = '43A73FAE-0C2C-4ED8-BE1E-B32C12DB163D')
AND year(ums_users.created) = '2005' and month(ums_users.created) = '01'
GROUP BY day(ums_users.created)
ORDER BY day(ums_users.created)


I'd be really grateful if somebody could explain what I'm doing wrong.

TIA

Nick

View 7 Replies View Related

Testing For Null Dataset

Dec 11, 2007



Hi All,

I need to find out how I can detect a NULL dataset at runtime. I have just released my first report using SQLServer Reporting services and all went well until I had an empty dataset on the server. There was no problem ever on my development system, running under Visual Studio 2005 Pro, even if I got no data back. Shortly after release to the server though I found that the report reported javascript errors. After a lot of searching I nailed it down to my code that alternated the background color of the rows in the report. The code looks like this:

=iif( RowNumber("DataRecords") Mod 2, "WhiteSmoke", "White")

I had this line in the BackGround property for my table row. It works great, unless DataRecords is Null and RowNumber is 0. I ended up taking the expression out, because I could not find a way to test if DataRecords was null or RowNumber was 0, without getting a compiler error.

Can anyone here tell me what I need to do so I can put that expression back in and alternate the color of my data rows again? I get the data using a stored procedure, if that matters.

TIA
URW

View 2 Replies View Related

Testing Null Values In SqlDataReader Row

Jun 3, 2008

Hi gang,
When reading a record from my SQL database for display on a web form, I am checking for null before I assign the value to a TextBox on the form. Here is an example:
 // normal database setup code hereSqlDataReader rdr = cmd.ExecuteReader();if (!Convert.IsDBNull(rdr["FirstName"])){    txtFirstName.Text = (string)rdr["FirstName"];}// code here for other record fields
Is this the correct way to do this? Is there a simpler way to do this? I am writing a bunch of database code and I want to do it right...
Thanks,Kevin

View 5 Replies View Related

Null Testing In Select Query

May 9, 2007

I am obviously a newbie to SQL Server but have been using Access for years and I have come up against what appears to be an age old issue concerning nulls and specifically the functions to test for them etc.

Below is the Access Query I am having difficulty with...
----------------------------------------------------------
SELECT DISTINCT Max(tbl_ScheduleDate.SchDate) AS CurrentDate, ([SchDate],"mmmm yyyy") AS MonthYear, tbl_Schedule.Area, tbl_Schedule.CP, IIf(IsNull(tbl_tmp_CP.CPID),"Not Uploaded","Uploaded") AS Loaded

FROM (tbl_Schedule INNER JOIN tbl_ScheduleDate ON tbl_Schedule.MaxMinID = tbl_ScheduleDate.MaxMinID) LEFT JOIN tbl_tmp_CP ON tbl_Schedule.CP = tbl_tmp_CP.CP

GROUP BY Format([SchDate],"mmmm yyyy"), tbl_Schedule.Area, tbl_Schedule.CP, IIf(IsNull(tbl_tmp_CP.CPID),"Not Uploaded","Uploaded"), tbl_ScheduleDate.SchDate, tbl_tmp_CP.CPID;
-------------------------------------------------------------

Ignore the Format() function as I know this is a problem and have a fix.

The problem is this field...
IIf(IsNull(tbl_tmp_CP.CPID),"Not Uploaded","Uploaded") AS Loaded

I am testing to see if data is loaded into table 'tbl_tmp_CP' that is related to 'tbl_Schedule' by checking if there is a null value or not and then adding the right response string value to a column called Loaded.

Can anyone suggest a way for me to do the above?

View 2 Replies View Related

Problem With Isnull. Need To Substitute Null If A Var Is Null And Compare It To Null And Return True

Sep 20, 2006

Hey. I need to substitute a value from a table if the input var is null. This is fine if the value coming from table is not null. But, it the table value is also null, it doesn't work. The problem I'm getting is in the isnull line which is in Dark green color because @inFileVersion is set to null explicitly and when the isnull function evaluates, value returned from DR.FileVersion is also null which is correct. I want the null=null to return true which is why i set ansi_nulls off. But it doesn't return anything. And the select statement should return something but in my case it returns null. If I comment the isnull statements in the where clause, everything works fine. Please tell me what am I doing wrong. Is it possible to do this without setting the ansi_nulls to off??? Thank you

set ansi_nulls off


go

declare

@inFileName VARCHAR (100),

@inFileSize INT,

@Id int,

@inlanguageid INT,

@inFileVersion VARCHAR (100),

@ExeState int

set @inFileName = 'A0006337.EXE'

set @inFileSize = 28796

set @Id= 1

set @inlanguageid =null

set @inFileVersion =NULL

set @ExeState =0

select Dr.StateID from table1 dR

where

DR.[FileName] = @inFileName

AND DR.FileSize =@inFileSize

AND DR.FileVersion = isnull(@inFileVersion,DR.FileVersion)

AND DR.languageid = isnull(@inlanguageid,null)

AND DR.[ID]= @ID

)

go

set ansi_nulls on

View 3 Replies View Related

Testing In IIS?

Jul 20, 2007

I have a website and database in Access, how do i set it up so i can test it in IIS using SQL server?

View 5 Replies View Related

Testing Transactions

May 21, 2008

I am using SqlServer 2005  Express Edition.  I have written a  stored procedure that has a transaction to make sure that it rolls back in case of failure.  Is there a way to test that the transaction works. I don't now how to cause an error that would cause the transaction to roll back and raise the error with the details of the exception.
 Thanks,
laura

View 2 Replies View Related

Need Help With Testing Query In Asp.

Dec 6, 2005

hello everyone i was hoping to get some help.
i have sql server2000 and iis5.1 running and im using vbscript through asp.
i have a table that has two keys so that together they make a unique key.
so i am trying to test my table in asp so that if there is a duplicate unique key inserted then show an
error...
Can anyone help me?

View 5 Replies View Related

Testing For NT And SQL Availability

Apr 13, 2001

I want to run remote procs from a local - central proc, but don't want to crash my proc if the remote NT Server or SQL Server is not available.
So, I want to test for NT and SQL availability first.

Here's my code.
====================
DECLARE
@DBName varchar(22),
@QueryString NVARCHAR(130),
@Resultsint,
@ResultsTxtvarchar(31)

/* I find the server-dbasename name in a lookup table, and then build dynamic script */
SELECT @DBName = "<SRVRNAME~DBASENAME>"
SELECT @QueryString = N'master..xp_cmdshell "ECHO >'
+ SUBSTRING(@DBName, 1,6)
+ 'pipesqlquery", no_output'
EXEC @Results = sp_executesql @QueryString

SELECT @Results /* <-- testing here.... */

=====================

If the NT / SQL is running, "@Results" should = 0 (success on the ECHO to the PIPE)
If the NT / SQL is NOT running, "@Results" should = 1 (error on the ECHO to the PIPE)

If I test in QA, I get the expected "@Results" values.

If I run the proc, I get "@Results" = 0 for both events, and them my proc fails on the remote proc call if the NT / SQL is NOT running.

I don't know how to write DMO in TSQL to try that.
I have also tried using 'odbcping' too.

HINTS? Better way to test remote NT / SQL is NOT running?

Thanks in advance.

View 1 Replies View Related

STRESS TESTING

May 1, 2001

Hi,
Is there anyway to test the loadtesting/Stress testing on SQLSERVER. I wanted to executes a Store procedure with concurrent users.

Thanks
JK

View 1 Replies View Related

Stress Testing

Dec 24, 2002

Anyone have a tool or script to run to test a SQL server under heavy stress?

View 1 Replies View Related

Testing Knowledge Of SQL And DTS

Mar 31, 2004

Hi,
I need help to test person's skills for
knowledge of SQL stored procedures
and DTS

Could someone point on good resources.


Thank you

Alex

View 4 Replies View Related

Testing Replication

May 7, 1999

i have performed all the steps for the replication there are two problems i encounytring
(i) how to check whether the replication is working or not
(ii) can replication on the subscribing server automatically create the table which publishing server is publshing
(iii)please tell me someother forums for sql server


what my knowledge says that in replication if i modify the data at one place it should automatically be modified in the subscribing server but this thing is also not happening (its not flashing any error message as such)
please tell me what all things i need to do to make sure that everything starts working

waiting for reply
ashish bhatnagar

View 1 Replies View Related

OLAP Testing

Jan 15, 2007

Hi Guyz ,

I'm new to this forum and as well as new to OLAP testing . I would like to know OLAP testing and guidance for SQL server anlaysis services .

I have been trying install SQL server 2000 in my system but it not going through, Can anybody send information how to install SQL server and how to play with sample database.

View 2 Replies View Related

Testing Queries

May 22, 2007

Has anyone ever heard of using Response.Write to test sql queries in the query designer? Here is the actual suggestion I was given recently:

Response.write your sql query. Copy the query to your db query tool and run the query. Adjust the query as necessary to return the recordset you desire. When you have the proper query, adjust your asp code.

The query editor/designer doesn't like certain symbols and extraneous code. So how exactly can you use Response.Write with a sql query without getting errors in designer?

View 4 Replies View Related

SQL 2005 Testing

Jul 23, 2005

I've begun some testing with the June beta of SQL 2005. One problemI've hit is with scalar-valued functions. The error I often get whenexecuting functions is "Select statements included within a functioncannot return data to a client.". These same functions are workingfine under SQL 2000.Has anybody seen this behavior or know what the deal is?

View 7 Replies View Related

Unit Testing

Oct 1, 2005

I've started researching on Unit Testing and I must admitI had never heard of Unit Testing until a couple of monthsago. Obviously I am interested in Unit Testing StoredProcedures.I read the TSQLUnit documentation (not all of it) and i also raninto a newsgroup post saying TSQLUnit is very small comparedto NUnit. The conclusion I am making out of this post is thatI should rather spend time resarching/reading about NUnit thanTSQLUnit. Is that a good assessment?I would like to you what you use and if you use actuallyUnit Testing or some other method? I ran into White Box/Black BoxQA testing. All these are new to me. Any good place to read about"Extreme Programming"? I ran into one link that I saved it at work.That's one place i will read more.Any links, documentation or books you would suggest?I searched Amazon and I didn't find anything interestingregarding SQL Server and Stored Procedures.Thank you

View 1 Replies View Related

Web Application Testing

May 25, 2006

I am running windows xp pro on my home computer and would like to test andatabase driven ASP .NET web application. I need to be able to create an SQLdatabase which will be assessed by the web application. I already have alocal IIS Server up and running.At work, I use SQL Enterprise Manager. I wanted to download it on my homecomputer but cannot find it anywhere on the net.How can I test my web applications at home on a person computer?Thanks.Jess

View 1 Replies View Related

Performance Testing

Feb 20, 2008



can any one guide me how should i do performance testing on database size for sql server.
I dont know how to read the execution plan, though i have read many document but still i am not clear.
For are the reports which shows the performance has been down and its all accurate.

View 26 Replies View Related

Unit Testing

Jun 20, 2005

Well was wondering this weekend. How do you do unit testing with SSIS? Is anyone trying it?

View 9 Replies View Related

Beta Testing SP1

Feb 6, 2006

Is it possible to get a list of all the fixes and enhancements that are going into SP1 for SSIS? This will make it alot easier to test seeing as we will know what we are looking for.

Regards

-Jamie

View 1 Replies View Related

Testing Replication

Aug 31, 2007

Hello Everyone

I am new to replication but i am into a project to test Transactional replication process , do anyone have any experience in this

If possible plz let me know what section i need to test .

Thanks in advance

Karthik

View 2 Replies View Related

Testing Failover

Sep 13, 2006

How do I test failover to point to the mirrored database instead of the principal without having to stop the primary instance? I would like to just bring the mirrored database on the primary instance to an offline status and see that the same database on the mirrored instance getting activated as the primary. This does not happen if I try to put the database on the primary server "offline" as it complains that any database that is being mirrored cannot be taken offline.

View 1 Replies View Related

Testing Subscriptions

Nov 23, 2007

At the moment, the only way (that I know of) to test a subscription seems to be to schedule it a few minutes ahead in time and wait for it to happen. Dies nayone know if there are plans for and "Execute" or "tTst" button? It would be nice to have one.

View 1 Replies View Related

Testing A Query?

Aug 1, 2007

i've been informed that one way to test a query is to execute and roll-back it back as a transaction. my question is the following: using the aforementioned mechanism, how can i examine the database state before the query is rolled-back?

View 2 Replies View Related

Load Testing

Jan 15, 2007

How does one determine in a VS load test the exact limit of the number of users the report server can handle without failing?

If 200 users proces request reports simultaneously, what is the best configuration for a single box deployment. The reports are parametrized reports and do not run from cache.

Thanks

Inder

View 4 Replies View Related

Testing SSIS

Jan 16, 2008

hi every one

can any one please explain me how to test manually SSIS packages

thanks in advance

View 3 Replies View Related

Reporting Services :: Give Meaning Full Name To Allow Null Value Check Box In Report Parameter Instead Of NULL?

Oct 20, 2015

In my report i have CNAME parameter , which allows null value. I checked Allow null value check box in report parameter properties.

when i preview the report , it displays checked NULL check box beside CNAME parameter . I want to give some meaningful name(i.e.ALLCustomers) to this checkbox instead of NULL. 

Is it possible through SSRS designer?

View 5 Replies View Related

Integration Services :: SSIS Insert Non Null Value Into Null Rows

Jul 15, 2015

I have a flat file with the following columns

SampleID   Rep_Number   Product  Protein   Fat   Solids

In the flat file SampleID and Product are populated in the first row only, rest of the rows only have values for Rep_Number, Protein, Fat, Solids.

SampleID and Product are blank for the rest of the rows. So my task is to fill those blank rows with the first row that has the sampleID and Product and load into the table.

View 7 Replies View Related

Testing For A Data Within A Datasource

Jul 10, 2007

Hi
I’ve got a simple SQLdataSource which is wired up to a gridView. When the page loads, it’s sometimes likely the data source would contain no data – how can I test for that in the code behind (no data)? I’d like to only show a button if there is data?
I’m using ASP.NET 2.0 with C#
Many thanksRichard

View 2 Replies View Related

Help With Testing A Dataset In Via Code Behind

Aug 10, 2007

Hi
I really need your help. I’ve got a table with 4 columns – username (a string of text), dateTime (a date and time), duration (time in minutes), roomID (URL). I really need some help with writing up some code behind to check if a user has permission to continue. I’ve got the first bit, but I need help with collecting the data and testing it:
            SqlConnection conn = new SqlConnection(Global.ConnectionString);            SqlCommand cmd = new SqlCommand("select * from tblActiveSession where Username=@Username", conn);
            SqlParameter paraUsername = cmd.Parameters.Add("@Username", SqlDbType.NVarChar);            paraUsername.Value = this.txtUsername.Text;
            try            {                conn.Open()
This is where I need the help. What I need is to test each row against the following:
If now() is within the allowed time frame – greater than dateTime, but less than dateTime + duration, then break the loop and redirect to roomID.
I really hope this makes sence, and I’m greatful for any help.
Many thanksRichard

View 13 Replies View Related

SQL Views And Testing For Nulls

Jul 6, 2004

Pop quiz hotshots:

I am creating a View in SQL2000 where i concatenate values from multiple tables. My problem is that if one of the values is null then the whole string is null, so I would like to know how to test for nulls within the Select part if the View.

Select
Titles.Title + ' ' + User.Forename + ' ' + User.Surname AS FullName,


For example;
If User.Forename is null, I still want to return Titles.Title and User.Surname as a concatenated string.

I’ve tried I few things like places if statements within the Select part but I can’t get it to work.

Many thanks

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved