I want to know how do we store null in the database
i know Null is unkown value
but it has to be something so the SQL server can know its null ( computer only knows 0s and 1s )
is it pointers and null does not have a pointer? or do we store something physically?
an example : we have string(varchar) column that has this value in it "Joey Tribbiani" that means in the hard disk we will see 14 bytes "Joey Tribbiani" in there, if we changed the value to "Monika" the 14 bytes will be replaced by 5 bytes "Monika", if we changed to empty strike then we will have 0 bytes ""
now if changed it to become NULL what is going to happen to the hard disk, what is going to be in there physically??
I have a form and a connectionString to a SQL database. If the textbox at the form is empty i want to store a null value there but when i pass this value as a parameter it brings the following error: Failed to convert parameter value from a String to a Int32.. cmd.Parameters("@Segundo_nombre").Value = txtSecondName.Text.ToString --> suposing is null it brings an Error. cmd.Parameters.Add(Apellido) How can i manage this? I want to store this value if it is null or not. Also i don't know how to assign a null value to a variable. I tried with v_flag = check_selection.check_string(v_idioma)
If v_flag = 1 Then 'la variable posee el texto Seleccione v_idioma = DBNull.Value but it's not working. Thanks!!
i am using csFindProperty store procedure in my application. here there are several input parameter are there. my procedure structure are:
ALTER PROCEDURE [dbo].[csFindProperty] @HouseNumber varchar(10), @Street varchar(100), @City varchar(100), @State varchar(2), @Zip varchar(15), @County varchar(25), @SquareFootageStart int, @SquareFootageEnd int, @Bedrooms int, @Bathrooms decimal(18, 2), @Garage decimal(18, 0), @Basement bit, @StyleID int, @Subdivision varchar(50), @SchoolDistrict varchar(50), @MonthlyRentStart money, @MonthlyRentEnd money, @ListPriceStart money, @ListPriceEnd money, @PetsAllowed bit AS select distinct hd.housenumber,hd.street,hd.city,hd.state,hd.zip, rd.monthlyrent,sd.listdate, sd.listprice from housedata hd, rentdata rd, saledata sd where hd.HouseNumber like @HouseNumber and hd.Street like @Street and hd.City like @City and hd.State like @State and hd.Zip like @Zip and hd.County like @County and hd.SquareFootage >= @SquareFootageStart and hd.SquareFootage <= @SquareFootageEnd and hd.Bedrooms like @Bedrooms and hd.Bathrooms like @Bathrooms and hd.Garage like @Garage and hd.Basement like @Basement and hd.StyleID like @StyleID and hd.Subdivision like @Subdivision and hd.SchoolDistrict like @SchoolDistrict and rd.MonthlyRent >=@MonthlyRentStart and rd.MonthlyRent <= @MonthlyRentEnd and sd.ListPrice >= @ListPriceStart and sd.ListPrice <= @ListPriceEnd and rd.PetsAllowed like @PetsAllowed and hd.HouseDataID=sd.HouseDataID
if the user enter in the column HouseNumber=1733 that value passed in sp @HouseNumber = N'1733', suppose user can not type any value in the column HouseNumber means, i assign the value HouseNumber='%'. HouseNumber is a varchar datatype.
what my question is: if the column datatype money or int or bit means what is the value i assign @Bedrooms = 2, this situation. since bedrooms is int datatype. if i assign @Bedrooms ='%', conversion error will occur. pls any one can help me come out this problem.
HI,ALL: I'm new to store procedure in sql 2000,now I create a sp to generate Balance report data , but when I run my sp in sql 2000 Query analyzer,I can get the data and some of data is null.
Now I want to replace null with '0' in my sp result data, is it possible to do it in store procedure in design model. ? how to get the soluation ?
We have a table with 10 columns each column is of datatype int and can accept nulls, when I do a save is it better to have 0 inserted in to the column or just insert null?
Hi Experts, I have an urgent needs. I want to store null for decimal type to sql server. But I do not know how to do that. I get data from user input. If the user did not enter anything in the textbox, then I want to store null to sql server. I list a piece od code below. I got error in the last line fItemObject.ChargeAmount = null;. if (!String.IsNullOrEmpty(txtDescription.Text)) myObject.LongDesc = txtLongDesc.Text; else myObject.LongDesc = null; if (!String.IsNullOrEmpty(txtAmount.Text)) myObject.Amount = Convert.ToDecimal(txtChargeAmount.Text); else myObject.ChargeAmount = null; // Then I submit the myobject to the sql server. Thank you very much in adavance!
We have a case where in we should show date based on conditions for e.g if we had a column defined as
col varchar(10) then we would show col as 'NULL' for some condition and actual value when no condition
Normaly date values are stored here e.g under col 20150901 .
Case when col>'20150901' then 'NULL' else col end as Derivedcol
Note this is an extract process and we are presenting data by pumping the data in a table .
Now there is another similar column -colz varchar(10) Â which stores date but doesnt have case condition so whenever date has no value its shows null which is database null.
So whats the difference between database null and string null ?
 How can we show database null for the case condition instead of string "null"?
I need to grant select, insert, update, and delete permission to an object residing in Database "X" from a store procedure in database "Y". I have already tried USE database statement. Any suggestion. Thanks Maroof Khan
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)
I'm just using TEXTBOX control to save data into my DB. My question is, if I have multiple lines of sentences, it does not store as what it looks like. For example;
Hello, Mike
It stores into the database as "Hello, Mike" and if I read from the database, it does not have seperate lines and shows it like this; Hello, Mike
How can I store the contents into database and make the contents as original? (Sorry for the poor English, but I hope you understand it.)
mo tu we th fr _______________________morning |___|____|_____|__X__|____|afternoon |___|_X__|_X__|__X__|____| evening |___|____|_X __|__X__|____|Hey guys, i have to store the values of the above table into the database however i have know idea how to design the table. Could you guys give me some suggestion.Currently i come up with the below solution.OpenTime---------------OpenTimeIDDateIDTimeIDDate------------DateIDDateNameTime-----------TimeIDTimeName
how can I store a filename in the database, i have some GIF files which i want to show up on report, how can i specify those filename with a path in the database. i tried manually entering the path c:Dataimages.gif but it didnt work. Can someone pls tell me how to do it.
Hi Anyone Knows I want to store SQL 2005 Existing Database into SQL Server Through .Net.if i give Database Name in .Net and that Database automatically stored in SQL Server 2005.P(including that Existing Database Tables and Stored Procedures).Please Help me.
Hi all, I want to find working duration between two datetimes in c#.i'm using following code... DateTime starttime = Convert.ToDateTime(Session["StartTime"]); DateTime endtime = DateTime.Now; TimeSpan duration = endtime - starttime; DateTime period = new DateTime(duration.Ticks); i want to store this duration in database through stored procedure, i've give datetime datatype to duration but it is giving error in conversion of TimeSpan to DateTime..Please help... Thanks
hi everybody,can anybody help me out by telling me how could I store images in a database, and how to insert new images at run time to a database and thanks
Hello, I am working on a project. We do not have a DBA, so I am performing some of these tasks. I recently created a new database with about 10 tables. I have set up the key and primary key relationships between the data files. How do I save the database through differenct stages of it's evolution? Suppose I populate the database, but later on decide that I we need to re-start from scratch and go back to the new database I created that is not populated. How do I save different versions of a database through it's evolution/progression? Thanks in advance, Bill
Hi FriendsCan anyone tell me how to store uploaded files from the user to the SQL database and later give an option of downloading the file probably in the form of a GridView control. How do we write code to allow the user to download the uploaded files. I have written code to upload and store the files into a folder, however, I'm not able to collect data from the folder later and the folder is only accessible offline using the server system which I do not want to happen. Can anyone help me with this?Thanks
hello all, I have a multi line textbox and want to store the content of the textbox to a database. I want to preserve the linefeeds so that I display the message as it is typed by retrieving it. Can anyone please explain how to store the linefeeds to the database. Once i store the linefeeds to the database, I can restore them using the Replace("","<br/>) method. But I can't figure out how to store the 's in the database in the first place. Thanx in advance
Hi i am creating a web page which will return the results of products, the store name and the distance of the store from the postcode which the user has put into a text box. My first question is how would my database structure look, below is what it looks like at the moment; Company; companyID, companyName, companyAddressLine1, companyAddressLine2, companyPostcode. and Products; productID, productName, companyID, price. In order to achieve the proximity search how would i alter the "Company" table, as in what columns will need to be added or removed, thank you.
in my local sql server,i want one of my databases store date in dd-mm-yy format,currently it stored in mm-dd-yy format,and i want this format specific to this database only,it should not affect on my other database.how can i get this??
hi, i would like to store images in my database and retirve them aswell. i have looked at examples on the net but i am finding it hard to follow and undertsand them, can anyone please give me adivse on how i can do this. i have alrady created my table in my database which has 4 fields pictureID, pictureContent, pictureType and pictureSize but i dont know where to go on from here. i want to do it in vb aswell. please any help and advise would be much appreciated as i am stuck, thank you
Hi I have a asp:FileUpload conponent that I am trying to use to retrieve a picture file from the clients pc and store it in a SQL database. The table is called PropertyImage and it contains the following fields: imgID (type = int - autoincrement); imgData (type = Image); imgTitle (type = VarChar); imgType (type = VarChar); imgLength (type = BigInt); I have a button (Button1) which when clicked calls Button1_Click() --------------------------------------------------protected void Button1_Click(object sender, EventArgs e) {byte[] fileData = null; Boolean status = false;if (FileUpload1 != null) { // Make sure the file has data.if ((FileUpload1.PostedFile != null) && (FileUpload1.PostedFile.ContentLength > 0)) { // Get the filename.string fn = System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName); try { // Access the file stream and begin the upload. Store the file in a memory byte array.Stream MyStream = FileUpload1.PostedFile.InputStream; long iLength = MyStream.Length;fileData = new byte[(int)MyStream.Length];MyStream.Read(fileData, 0, (int)MyStream.Length); MyStream.Close(); }catch (Exception ex) { } } }SqlConnection connection = new SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\heidihomes.mdf;Integrated Security=True;User Instance=True"); try { connection.Open();SqlCommand sqlCmd = new SqlCommand("INSERT INTO PropertyImage (imgData, imgaTitle, imgType, imgLength) VALUES(@data,@title,@type,@length)"); SqlParameter param = new SqlParameter(); // String connectionString = new SqlConnection(sqlCmd, connection); param = new SqlParameter("@data", SqlDbType.Image); param.Value = fileData; sqlCmd.Parameters.Add(param);param = new SqlParameter("@title", SqlDbType.VarChar); param.Value = fileData; sqlCmd.Parameters.Add(param);param = new SqlParameter("@type", SqlDbType.VarChar); param.Value = fileData; sqlCmd.Parameters.Add(param);param = new SqlParameter("@length", SqlDbType.BigInt); param.Value = fileData; sqlCmd.Parameters.Add(param); sqlCmd.ExecuteNonQuery(); connection.Close();status = true; }catch (Exception ex){ }if (status) { UploadStatus.Text = "File Uploaded Successfully";Server.Transfer("Admin_PropertyView.aspx"); } else {UploadStatus.Text = "Uploaded Failed"; } } } -------------------------------------------------- But when I click on the button, nothing happens. Please could someone help me out here. I have tried this a few times and still haven't come right. Also, if there is something else wrong with the code, please let me know. Thanking you in advance.
i want to store a date into sqlserver database using stored procedure. when i run app. it will give this error....... ---------------------------------- Server Error in '/aspnet/espms' Application. --------------------------------------------------------------------------------
String was not recognized as a valid DateTime. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.FormatException: String was not recognized as a valid DateTime.
Source Error:
Line 349: cmd.Parameters(6).Value = CType(ddldeltype.SelectedValue, Integer) Line 350: cmd.Parameters(7).Value = txtshipnm.Text Line 351: If cmd.ExecuteNonQuery Then Line 352: add = True Line 353: Else