Mutator 'FirstName' On '@test' Cannot Be Called On A Null Value.

Apr 11, 2007

I'm having trouble figuring out how to use a UDT class. I'm simply trying to test out the class in a query window in the management studio. Here's the simple snippet:



declare @test TestObject;

set @test.FirstName = 'bob'

select @test.FirstName



Obviously my object has a string property called FirstName. When I execute this simple query I get the following error:



Mutator 'FirstName' on '@test' cannot be called on a null value.





Any ideas?

View 1 Replies


ADVERTISEMENT

Returned SQLParam.SqlValue Is {Null} But Can't Test For Null?

Nov 5, 2007

I run a stored procedure for which I have a return variable. The stored procedure returns the ID of a row in a table if it exists:

m_sqlCmd.ExecuteScalar();

The m_sqlCmd has been fed an SQLParameter with direction set to output.
When the stored proc returns, I want to test it. Now when there IS a row it returns the ID ok.
When the row doesn't exist, in my watch I have:

m_sqlParam.SqlValue with value {Null}

I can't seem to work out how to test this value out.
I've tried several things but none seem to work.

This line compiles ok, but the following runs into the IF statement as if the SqlValue is null??

if (m_sqlParam.SqlValue != null)....
{

// I'm here!! I thought the watch says this is null???
}

Sorry if this is obvious, but I can't work this one out!!

View 3 Replies View Related

Test For Null In Row

Nov 18, 2005

I have a stored procedure which runs a query, then turns it on its side (so that the rows are column headers).What I need to do now is test if any of the values in a row from this stored procedure are null.Any suggestions on how to get started?  Is there some function that will tell me if any value in the row is null?

View 2 Replies View Related

Retrieving An Image From SQL, Test For Null

Sep 28, 2007

I have an employee directory application that displays employees in a gridview.  When a record is selected, a new page opens and displays all info about the employee, including their photo.  I have the code working that displays the photos, however, when no photo is present an exception is thrown that "Unable to cast object of type System.DbNull to System.Byte[]".  I'm not sure how to test for no photo before trying to write it out. 
My code is as follows (with no error trapping):
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load, Me.Load
Dim temp As String
Dim connPhoto As System.Data.SqlClient.SqlConnection
Dim connstring As Stringconnstring = Web.Configuration.WebConfigurationManager.ConnectionStrings("connPhoto").ConnectionString
connPhoto = New System.Data.SqlClient.SqlConnection(connstring)temp = Request.QueryString("id")
Dim SqlSelectCommand2 As System.Data.SqlClient.SqlCommand
Dim sqlstring As String
sqlstring = "Select * from dbo.PhotoDir WHERE (CMS_ID = " + temp + ")"SqlSelectCommand2 = New System.Data.SqlClient.SqlCommand(sqlstring, connPhoto)
Try
connPhoto.Open()Dim myDataReader As System.Data.SqlClient.SqlDataReader
myDataReader = SqlSelectCommand2.ExecuteReader
Do While (myDataReader.Read())
Response.BinaryWrite(myDataReader.Item("ImportedPhoto"))
Loop
connPhoto.Close()Catch SQLexec As System.Data.SqlClient.SqlException
Response.Write("Read Failed : " & SQLexec.ToString())
End TryEnd Sub
End Class

View 2 Replies View Related

How To Test If A Column Returns Null Or Not Using The Reader Object?

Apr 11, 2008

Is there a way to check for System.BDNull when I use the column name instead of column index? The column Photographer (in the excample below) sometimes contains the value null, and then it throws an error. Or do I have to go back to counting columns (column index of the returned data) again?                try {                    connection.Open();                    using (SqlDataReader reader = command.ExecuteReader()) {                        if (reader.Read()) {                            albumItem = new Album((int)reader["Id"]);                            if (reader["Photographer"] != null)                                albumItem.Photographer = (string)reader["Photographer"];                            albumItem.Public = (bool)reader["IsPublic"];                        }                    }                } Regards, Sigurd 

View 2 Replies View Related

How To Parse Field LastName,FirstName

Dec 7, 2007

Hello, I need some help being pointed in the right direction. I have a field in my Customer table called Name that is "LastName,FirstName". I need to be able to return a result set with "FirstName,LastName". Any ideas?

View 14 Replies View Related

Transact SQL :: To Get FirstName And LastName From One Word

Aug 25, 2015

How to retrieve data as a two names from one columns.

For example: My column has naming like this  Shannon.Cooley, I want to display like this:

FirstName         LastName                           FullName
Shannon         Cooley                           
Shannon  Cooley

How to write the query to get the above table?

View 7 Replies View Related

An Interesting Lastname, Firstname, Middlename Challenge

Sep 6, 2006

I'm sure you all have seen situations where a field has a combined namein the format of "Lastname, Firstname Middlename" and I've seenexamples of parsing that type of field. But what happens when the datawithin this type of field is inconsistent? Here are some examplesApple, John A.Berry John B.CherryJohn CDonald John DHow does one parse the data when the data isn't consistent?

View 2 Replies View Related

What's The Equivalen Function Of StrConv ([FirstName] , 3 ) In ACCESS In Sql Server 2000?

Jul 20, 2005

HI,i got a problem while using StrConv function in sql server.My requirement is:-suppose in a name field i have "jhon smith" Now i want to run a sqlwhich will give me the result like "Jhon Smith"--which means uppercase first.Now i am running a query like below which is giving me "Jhon smith"but i want "Jhon Smith".SELECT [CustomerID] ,upper(left(firstname,1)) + lower(right(firstname,len(firstname)-1)) AS [FirstName_] from my_table;But the above query is not giving me the right result. Pleasesuggest...ThanksHoque

View 2 Replies View Related

DB Engine :: Replicate A Master Test Database To 100 Test Environments?

Oct 12, 2015

We are setting up a test lab environment with 100 machines.  We want one master testing db that gets replicated to each to run scripted application tests nightly.  

My goal is to minimize the amount of work to move this thing to each of the 100 test machines.  I am wondering if we need to even have the sql local and invest in a monster db server with 100 copies of the db we restore and each test machine point to their own db on that server, or if I should use db mirroring or something to get the master test db to each of those machines instead.

View 6 Replies View Related

Unit Testing For SSIS - To Test Or Not To Test?

Oct 17, 2006

Now that we have a good programming model in SSIS - the question is whether to write automated unit tests for your packages, and would it generally be a good idea for packages?

Also - if yes to write tests - then where to find more informations regarding How to accomplish that?

View 1 Replies View Related

How To Test SSis Package And What Are The Things I Need To Test It ?

Nov 27, 2007



hi every one,
i need to test SSIS pacakge which will import data from different database where record count is around 5 millions.
iam planning to test it through c# code as well as manually also.
SSIS source : consist of 7 tables
SSIS destination :consist of 7 tables
Using c# code iam trying to run ssis package through batch file.
i am putting expected rowcount, column count in an excel file and comparing same with destination tables by writing query implementing ADO.Net concept.
am i going right way ,can any one suggest best and productive way to test the ssis package .
what are the other things i need to test it.
do any one can add test cases to it.






S.No

Test Case


1

Verify all the tables have been imported.



2

Verify all the rows in each table have been imported.



3

Verify all the columns specified in source query for each table have been imported


4

Verify all the data has been received without any truncation for each column.



5

Verify the schema at source and destination



6

Verify the time taken /speed for data transfer


7

Fields truncated due to difference in length of the field at destination.
Regards
Arif shareef

View 9 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

SQL 2012 :: Restore DB From Prod To Test - How To Restore Users In Test

Jun 25, 2015

I need to restore test DB from production backup but once it is restored I would need all the permissions of sql logins and windows AD account intact in test Db as it was before.

View 4 Replies View Related

What Is This Called?

Mar 11, 2008

Hi,
I just want to know how do you called when you are accessing another pc thru \. I forgot how it is called.

Second, I like to know what [MACH] and [INST]. They don't look like directories.

\MultforestHEALTH[MACH][INST]HEALTH_WAREHOUSEDeploy_20080228p_Vitals_FACT.sql'

View 9 Replies View Related

Called Web Page From DTS

Jan 16, 2004

How can I execute or access a web page from a DTS package?

Both SQL server AND website are hosted on the same server (a Dual 2.4Gz Xeon with 2Gb RAM, RAID 5 etc)

I have 2 tables in SQL server 2000 that hold orders. These need to be posted into another table at a predefined time (ie: 4:30pm) and at the same time, access a remote address (a web service) and post certain elements of the order back.

Basically, can anyone help me out on how to execute a web page from a DTS.

I do NOT want to access a DTS from a webpage, which is all I'm finding at the moment.

View 5 Replies View Related

Coinitialization Has Not Been Called

Oct 17, 2001

Hello,
Question is, when I try to create relationships in SQL 7 without using the wizard..upon adding the tables I get an errror message that says "Coinitialization has not been called". What does this mean?

View 1 Replies View Related

How Do I Specify More Than I Argument In A Called SP?

Jan 24, 2007

CREATE PROCEDURE sp_getT
@m1 int ,
@txn int ,
@Pan varchar(50) ,
@Act varchar(50) OUTPUT,
@Bal Decimal(19,4) OUTPUT,
@CBal Decimal(19,4) OUTPUT
AS

declare @pBal money, @pCbal money, @pAct money
SET NOCOUNT ON


IF @m1 = 200
BEGIN
IF @txn = 31
BEGIN
exec ChkBal @Pan, @pBal output, @pCbal output, @pAct out
END
END

SET @Act = @pAct
SET @Bal = cast(@pBal as Decimal(19,4))
SET @CBal = cast(@pCBal as Decimal(19,4))

return @Act
return @Bal
return @CBal

the above code returns this error message

"Server: Msg 8144, Level 16, State 2, Procedure CheckBalance, Line 0
Procedure or function ChkBal has too many arguments specified."


How do i specify all the arguments i want in the called procedure?

View 14 Replies View Related

What Is This Methodology Called

Jul 31, 2007

Hi everyone -

I'm stumped on what to cal this, there might even be
a method or pattern named for what i am trying to accomplish...

In the database, a number field is included on each table

When the DAL reads the record from the database, it is passed to
the client - work is possibly done to the record and is sent
back to the DAL for update.

A query is done against the table to retrieve the record again,
the numbers are compared - if they don't match, it is assumed the record
been modified by another user/thread/activity. An error is returned to the client stating the data has been changed.

if the numbers match, the record is updated with the number field being incremented by one.

what is this methodology called (beside crap :-) )


thanks
tony

View 7 Replies View Related

Need A So-Called SSN Encryption

Mar 30, 2006

Hello, perhaps you guys have heard this before in the past, but here iswhat I'm looking for.I have a SQL 2000 table with Social security numbers. We need tocreate a Member ID using the Member's real SSN but since we are notallowed to use the exact SSN, we need to add 1 to each number in theSSN. That way, the new SSN would be the new Member ID.For example:if the real SSN is: 340-53-7098 the MemberID would be 451-64-8109.Sounds simply enough, but I can't seem to get it straight.I need this number to be created using a query, as this query is areport's record source.Again, any help would be appreciated it.

View 9 Replies View Related

SelectedIndexChanged Not Being Called

Jan 19, 2007



Hi

I have a drop down list which gets populated from database but I want to add the default value as

--Select----



View 4 Replies View Related

How Triggers Are Called

Apr 22, 2008

This seems like a basic question but I have not been able to find the answer in the help files or by searching this forum.

Is a trigger called for each row updated or is it called once for all rows updated?

for example if I have:



Code Snippet
CREATE TRIGGER mytrigger

ON mytable
AFTER UPDATE
AS
BEGIN

EXEC e-mail-me inserted, N'mytrigger', getdate()
END



and I do this



Code Snippet
UPDATE mytable
SET mycolumn = N'whatever'
WHERE ID > 5 AND ID <= 10



Assuming there is a record for each nteger value of ID, than will mytrigger run 5 times (once for each row updated) or one time (with inserted containing all 5 rows)?

View 3 Replies View Related

UDF Used In SubQuery: Is It Called At EACH Row?

May 6, 2008

Hi,

When a column is evaluated against an UDF in a SELECT ... or WHERE ... It makes sense that the UDF is called for every row of the SELECT. But is it still true if the UDF is called in a subquery as below?





Code Snippet

SELECT LineID, AnyText FROM dbo.UdfTest WHERE LineID IN (SELECT LineID FROM dbo.F_Bogus())
I've made a test and the SQL Profiler Trace shows that the UDF is called only once.

Can anyone confirm if my test is valid and most importantly that the UDF is called only once? FYI, I never use sub queries. This is to clarify a technical detail for our performance investigation.

Thank in advance for any help.


Here is the code to setup the test:
USE NorthWind
GO

CREATE TABLE dbo.UdfTest (
LineID int Identity(1,1) NOT NULL,
AnyText varchar(200) COLLATE database_default NOT NULL
)
GO

INSERT dbo.UdfTest (AnyText) VALUES ('Test1')
INSERT dbo.UdfTest (AnyText) VALUES ('Test2')
INSERT dbo.UdfTest (AnyText) VALUES ('Test3')
GO

CREATE FUNCTION dbo.F_Bogus (
)
RETURNS @tab TABLE (
LineID int NOT NULL,
AnyText varchar(100) COLLATE database_default NOT NULL)
AS
BEGIN
INSERT @tab (LineID, AnyText) VALUES (1, 'UDF1')
INSERT @tab (LineID, AnyText) VALUES (2, 'UDF2')
INSERT @tab (LineID, AnyText) VALUES (3, 'UDF3')
INSERT @tab (LineID, AnyText) VALUES (4, 'UDF4')
INSERT @tab (LineID, AnyText) VALUES (5, 'UDF4')

RETURN
END
GO

Here is the capture of SQL Profiler when executing the statement:
SELECT LineID, AnyText FROM dbo.UdfTest WHERE LineID IN (SELECT LineID FROM dbo.F_Bogus())

SQL:BatchStarting SELECT LineID, AnyText FROM dbo.UdfTest WHERE LineID IN (SELECT LineID FROM dbo.F_Bogus()) 51 2008-05-06 17:58:31.543
SQLtmtStarting SELECT LineID, AnyText FROM dbo.UdfTest WHERE LineID IN (SELECT LineID FROM dbo.F_Bogus()) 51 2008-05-06 17:58:31.543
SPtarting SELECT LineID, AnyText FROM dbo.UdfTest WHERE LineID IN (SELECT LineID FROM dbo.F_Bogus()) 51 2008-05-06 17:58:31.577
SPtmtCompleted -- F_Bogus INSERT @tab (LineID, AnyText) VALUES (1, 'UDF1') 51 2008-05-06 17:58:31.577
SPtmtCompleted -- F_Bogus INSERT @tab (LineID, AnyText) VALUES (2, 'UDF2') 51 2008-05-06 17:58:31.577
SPtmtCompleted -- F_Bogus INSERT @tab (LineID, AnyText) VALUES (3, 'UDF3') 51 2008-05-06 17:58:31.577
SPtmtCompleted -- F_Bogus INSERT @tab (LineID, AnyText) VALUES (4, 'UDF4') 51 2008-05-06 17:58:31.577
SPtmtCompleted -- F_Bogus INSERT @tab (LineID, AnyText) VALUES (5, 'UDF4') 51 2008-05-06 17:58:31.577
SPtmtCompleted -- F_Bogus RETURN 51 2008-05-06 17:58:31.577
SQLtmtCompleted SELECT LineID, AnyText FROM dbo.UdfTest WHERE LineID IN (SELECT LineID FROM dbo.F_Bogus()) 51 2008-05-06 17:58:31.543
SQL:BatchCompleted SELECT LineID, AnyText FROM dbo.UdfTest WHERE LineID IN (SELECT LineID FROM dbo.F_Bogus()) 51 2008-05-06 17:58:31.543

View 5 Replies View Related

Trigger Not Being Called

Aug 20, 2007

My package inserts rows into tables with triggers.

The triggers are not being called.

What might be causing this?

View 1 Replies View Related

How To Check Which Tables Were Called?

Oct 12, 2005

Hello everyone:

I have some nightly jobs that execute stored procedure to call the tables? I want to know which table are called by these stored procedures. Is it possible? Any idea will be appreciated.

Thanks

ZYT

View 5 Replies View Related

Procedure Sp_sqlagent_log_jobhistory Not Being Called

Oct 13, 2007



I am encountering an issue which is effecting our production environment, none of our sql jobs are now saving any kind of job history, nor are the status of the jobs being saved.
I have run a profiler trace and it seems as if procedure : sp_sqlagent_log_jobhistory is not being called during the execution of any of our jobs
Has anyone else encountered anything similar?

View 3 Replies View Related

SP Not Working Correctly? When Called From App

May 3, 2006

Hi

In a stored procedure the following code snippet 1 checks against duplicate data being inserted. I've tested it with snippet 2 and it works as expected. However, when the procedure is called from ASP.NET the check seems ineffective. I still get the error msg. The application uses a SqlDataSource with the following parameters.

Any suggestions?

Thanks,

Bakis.

PS I want to ask a question on the ASP.NET forum .The login/pwd for this forum "get me in" to the .net forum in the sense that when I log in I see a logout link. I don't get an "ask a question" button though. Is there a separate screening for each forum?

<UpdateParameters>

<asp:Parameter Name="CatItemUID" Type="Int32" />

<asp:Parameter Name="CatName" Type="String" />

<asp:Parameter Name="Item" Type="String" />

<asp:Parameter Name="Quad" Type="Int16" />

<asp:Parameter Name="UID" Type="Int64" />

</UpdateParameters>



snippet 1 :

if (@CatItemComboExists > 0 )
BEGIN
--print @CatItemComboExists
return 0
END

snippet 2:

begin tran
declare @return_status int
EXECUTE @return_status = spUpdateCatItemRec 343, 'blah','blih', 2,3
print @return_status
rollback

error msg only if proc is called from app

Violation of UNIQUE KEY constraint 'IX_tblCatItemUID'. Cannot insert duplicate key in object 'tblCatItemUID'.

View 3 Replies View Related

Need To Find Out The Name Of My Stored Proce Being Called. How Can I Do This?

Oct 12, 2006

I am maintaining some C# and ASP.NET code with SQL server 2000. My code calls a stored procedure. The code is a little confusing as to the name of the SQL Server stored procedure that is calling. At this point I don't know how to trace into or debug the stored procedure. Kind of hard to do in the first place when you are not absolutely certain as to the stored proc to be called.I can take an educated guess as to which stored procedure is being called. I figure if I can deliberately make a certain stored procedure fail then this might be able to somehow give me the name of the stored proc that I am calling.So is there a way to do this. Namely make a stored procedure fail, or to return the name of the stored Proc?I would sincerely appreciate some help with this problem.

View 1 Replies View Related

SqlDataSource And Stored Procedure Not Getting Called

Feb 23, 2007

Im using a SqlDataSource control. Ive got my "selectcommand" set to the procedure name, the "selectcommandtype" set to "storedprocedure"What am i doing wrong ?  Ive got a Sql 2005 trace window open and NO sql statements are coming through  "ds" runat="server" ConnectionString="&lt;%$ ConnectionStrings:myConnectionString %>" SelectCommand="my_proc_name" SelectCommandType="StoredProcedure">

"txtF1" Name="param1" Type="String" />
"txtF2" Name="param2" Type="String" />
"" FormField="txtF3" Name="param3" Type="String" />
"" FormField="txtF4" Name="param4" Type="String" />



  

View 2 Replies View Related

Store Procedure Called - Timeout

Sep 12, 2005

Hi All,I have a report ASP.NET page that allow users to run a report by clicking a buttion to call a store procedure to generate the report, however, the store procedure is taking a few minutes to return the data, thus I got the 'timeout' error message on my page. How do I extend the time on my page?Thanks

View 3 Replies View Related

How-to Return Calculated Values From A Called SP

Dec 11, 2001

Can someone please reply w/ example syntax on how to receive calculated variables from an invoked SP. DESCRIPTION:

sp_caller invokes sp_calc_values (passing @var1, @var2) via:
exec sp_calc_values @var1, @var2

sp_calc_values receives @var1, @var2 then calculates @var3, @var4

HOW does sp_caller receive the calculated values @var3, @var4 ???

thx in advance

View 2 Replies View Related

Different Behaviour Of A SP Called From SQL Query And From MS Access

Feb 2, 1999

Hi,
Please help me to elucidate a mistery !

I have a little SP in a database:

CREATE PROCEDURE XXXTest AS

DECLARE @a varchar(50)

SELECT @a = NULL

IF @a NOT IN ('x', 'y')
BEGIN
RAISERROR ('Error',16,1)
RETURN 0
END
RETURN 1

If I execute it from SQL Server, it returns 0. (after the error, of course).
If I execute it from MS ACCess through a Pass Through Query, it returns 0.
On the same server !!!
How could it to make me that ? I have been thought the SP is executed entirely on the server !!!

Thanks in advance clearing me the mind.
Mircea.

View 2 Replies View Related

What Is Called In Sqlserver For RPAD And LPAD?

May 31, 2001

Running sqlserver 2000
In oracle, it is called rpad and lpad for adding character to the left of
the output string or right of the output string.

Example,

I am selecting a zip_code 10200 and it truncates last 2 zeros when I
run select on the table.

If I just run select zip_code from test;

I will receive following result in oracle.

102


So, I run select rpad(zip_code,5,'0') from test;

This will add last two zeros to the the string.


Result in Oracle;
10200

How can you do this in sqlserver?

Please let me know.

Thanks,
Ranjan

View 2 Replies View Related







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