What Is The Best Way To Get Empty Date?
Feb 20, 2008
tbl_store
id numeric(9)
enddate datetime(8)
tbl_store Data
ID Enddate
1 01/02/2020
2
3 01/02/2010
4
5 01/02/2001
(empty enddate data is showing <null>)
This is my query...but i want to get date empty records too.
select * from tbl_store where Enddate> '02/20/2008'
I want output
1 01/02/2020
2
3 01/02/2010
4
View 21 Replies
ADVERTISEMENT
Oct 11, 2004
undefined
I am using VB6 and SQL7. I am asking a user to enter a date if applicable - specifically a product manufactured date. I then take that date, using the dateadd function, query a table for a specific code, and calculate an expiration date based on the particular code.
The problem - if the user does not enter a manufactured date, which is OK, SQL inserts 01/01/1900 - which I do not want. How do I handle?
I am inserting the date, if there is one, from a flexgrid. I am declaring the variable as variant. The SQL field is DateTime.
Ex:
sSQL = "Insert into RecI(manufacdate) values ('" & (flxRec.TextMatrix(ctr,14)) & "')"
Please Help!
View 2 Replies
View Related
May 23, 2006
Hi,
I have update function that updating sql database table.
In the table I have fields like: name, address, phone, …, install_date
updateScreen(txtSName.text, txtSLocation.text, txtSPhone.text, txtSAddress.text, txtSPostal.text, ddSCity.SelectedItem.text, ddSCountry.SelectedItem.text, txtSOwner.text, txtSInstall.text )
The function work fine except the part whent install_date field is empty then I have the following message:
System.InvalidCastException: Conversion from string "" to type 'Date' is not valid.
Ii would like to use the same update function to make an updates even when date field is empty.
If someone has any idea how make it work, I would appreciate that
Alex
View 4 Replies
View Related
Jan 8, 2008
Hi, how do I convert dates with SSIS, when I receive dates I have no problem, with empty fields I have to go through a transformation as:
trim(field_name) == "" ? "999999" : substring....... (derive transform)
after this I have to update each field holding '999999' to NULL. (using sql task)
Is there an easier way to doing this?
Thanks
View 1 Replies
View Related
Aug 10, 2007
Hi
I am making a report in Visual Studio. I€™m making a matrix report. I have made a UNION of 2 tables. One of them has a field called Date and the other one does not. But to make a UNION of these 2 tables so that the results are printed in a Matrix I have to have the same fields€™ aliases at least. So what I did is that in the second table is:
SELECT €˜ €˜ AS €˜Date€™
Right?
Now, in the report the first table gives me the dates in a format:
=Format(Fields!Estimated_Close_Date.Value, "yyyy-MM-dd")
But, the second table is it doesn€™t have a date in that field when I run the report it gives me:
1900-01-01
Something I don€™t want.
So, how do I make it understand that the second tables date field is suppose to be empty?
View 8 Replies
View Related
Sep 21, 2006
HiI am using SQL 2005, VB 2005I am trying to insert a record using parameters using the following code as per MotLey suggestion and it works finestring insertSQL; insertSQL = "INSERT INTO Issue(ProjectID, TypeofEntryID, PriorityID ,Title, Area) VALUES (@ProjectID, @TypeofEntryID, @PriorityID ,@Title, @Area)"; cmdInsert SqlCommand; cmdInsert=new SqlCommand(insertSQL,conn); cmdInsert.Parameters.Add("@ProjectID",SqlDbType.Varchar).Value=ProjectID.Text; My query is how to detail with dates my previous code wasinsertSQL += "convert(datetime,'" + DateTime.Now.ToString("dd/MM/yy") + "',3), '";I tried the code below but the record doesn't save?string date = DateTime.Now.ToString("dd/MM/yy"); insertSQL = "INSERT INTO WorkFlow(IssueID, TaskID, TaskDone, Date ,StaffID) VALUES (@IDIssue, @IDTask, @TaskDone, convert(DateTime,@Date,3),@IDStaff)"; cmdInsert.Parameters.Add("IDIssue", SqlDbType.Int).Value = IDIssue.ToString();cmdInsert.Parameters.Add("IDTask",SqlDbType.Int).Value = IDTask.Text;cmdInsert.Parameters.Add("TaskDone",SqlDbType.VarChar).Value = TaskDoneTxtbox.Text;cmdInsert.Parameters.Add("Date",SqlDbType.DateTime).Value = date;cmdInsert.Parameters.Add("IDStaff",SqlDbType.Int).Value = IDStaff.Text;Could someone point to me in the right direction?Thanks in advance
View 3 Replies
View Related
Jun 13, 2002
In SQL Server 2000:
How do I convert a Julian date to a Gregorian date?
How do I convert a Gregorian date to Julian?
Examples please.
Many thanks in advance.
Gary Andrews
View 2 Replies
View Related
Jul 29, 2015
My goal is to select values from the same date range for a month on month view to compare values month over month. I've tried using the date trunc function but I'm not sure what the best way to attack this is. My thoughts are I need to somehow select first day of every month + interval 'x days' (but I don't know the syntax).In other words, I want to see
Select
Jan 1- 23rd
feb 1-23rd
march 1-23rd
april 1-23rd
,value
from
table
View 9 Replies
View Related
Sep 29, 2006
SQL Server 2000 SP4. Hoping to find a logical explanation for a certainbehavior.Consider this script:USE pubsGOIF 1 = ALL (SELECT contract FROM dbo.authors WHERE state = 'CA')PRINT 'TRUE'ELSEPRINT 'FALSE'This, as expected, prints FALSE, since not all authors in CA are undercontract. Now, if the script is changed as follows:USE pubsGOIF 1 = ALL (SELECT contract FROM dbo.authors WHERE state = '')PRINT 'TRUE'ELSEPRINT 'FALSE'then the result is TRUE. In other words, the expression evaluates to TRUEwhen the select statement produces an empty set, which doesn't make senseto me. Even more interesting, the expressionNULL = ALL (SELECT contract FROM dbo.authors WHERE state = '')still evaluates to TRUE (ANSI_NULLS is ON).Can anyone explain these results? Is this the expected behavior in the SQLstandard, or something that is specific to SQL Server? Thanks.--remove a 9 to reply by email
View 5 Replies
View Related
Feb 26, 2007
@Names is a query string passed in, I need to count the number of records as a result of the below query/
Dim test As String
Dim sqlConnection3 As New SqlConnection("data Source=EQ-520-WEBSQLEXPRESS;Initial Catalog=CRDB.MDF;Integrated Security=True")
Dim cmd As New SqlCommand
Dim returnValue As Object
cmd.CommandText = "SELECT COUNT(ReqID) AS Expr1, LineManager FROM TblReqMain GROUP BY LineManager HAVING (LineManager = @Names)"
cmd.CommandType = Data.CommandType.Text
cmd.Connection = sqlConnection3
cmd.Parameters.Add("@Names", Data.SqlDbType.NVarChar)
sqlConnection3.Open()
cmd.Parameters("@Names").Value = test
If test = "" Then
Response.Write("An error occured")
Exit Sub
Else
returnValue = cmd.ExecuteScalar()
sqlConnection3.Close()
Label6.Text = "Number " & returnValue
View 1 Replies
View Related
Feb 12, 2008
I am fetching records from a table and putting in a datatable using the "sqlda.fill(datatable)"
when i see the datable in "data visualizer" i find no rows.
It is confused eventhough it does not throw any error
View 3 Replies
View Related
Mar 14, 2008
Hi, is there an equivalent to the mysql's " INSERT INTO table () VALUES ();"? The fields don't allow null values, and there is a primary key with auto increment. Any ideas?Thanks a lot.
View 7 Replies
View Related
Jun 28, 2004
Hi i would like to know how to empty the transaction log programmaticly.
Someone got a clue? :)
View 6 Replies
View Related
Jan 26, 2000
Hi, I have a SQL Server 6.50 - 6.50.415 (Intel X86) and one database has 8Gb of data and 2Gb of log, the problem is that
the log space used is never below 44%, even if I back it up this way:
DUMP TRANSACTION DBName TO DBNAME_log_930 VOLUME = 'SS0003' WITH NOUNLOAD , STATS = 10, INIT , NOSKIP
This should clean the log, right?
I check for open transactions via: dbcc opentran (GMS), but there aren't.
The way I check for the log space used is: dbcc sqlperf(logspace)
The recover interval is 5.
Any Ideas?
Thank You
Gaspar Gonzalez
View 2 Replies
View Related
Jun 27, 2005
i have a sql sever2000 , and few disk.
when i am doing many opertaion , the log file is full. so how can i empty it?
sorry for my bad english
View 2 Replies
View Related
Feb 27, 2006
I'm bcp-ing a table to a file. I've noticed that if a varchar column is empty, that both "bcp -c" and "bcp -c -k" export the empty value as #$00. Instead, I'd like to export the value as if it were null.
use monkey
go
create table tab1 (
myColumn varchar(10) null
)
go
insert into tab1 (myColumn) values ('')
go
exec master..xp_cmdshell 'bcp monkey..tab1 out D:data.csv -c -T'
go
drop table tab1
go
I've been fiddling about with other switches but so far haven't come up with a solution other than writing out the full SELECT-statement or updating the original. Anyone with an easier solution?
View 3 Replies
View Related
May 14, 2007
hi everyone,
i was just wondering, is there anyway to empty a table...like, in mysql u can go EMPTY TABLE
and it resets the identity stuff, so your id's start at zero again...?
Thanks, Justin
View 4 Replies
View Related
Mar 23, 2006
hello everyone,
am not sure if this is the right forum, but here goes.
We have a couple of clients we support running MS SQL, and as a rule, all db access is by SP and select statements.
However, we noticed earlier today, that a newly created account was empty. All columns except the users columns had been deleted.
1. Is there a way of checking which user account deleted the columns ?
2. Or finding out what went wrong ?
This has never happened before
Afrika
View 3 Replies
View Related
Apr 19, 2007
Okay, so i have a procedure where i'm trying to build a left join, and for some
reason, if i store it into a procedure, it doesnt work, if i run it in query analyzer
i have no problem.
Manual Code:
create PROCEDURE search_orders_11
@SPSirvarchar(3)= null,
@debug bit = 0 AS
DECLARE @sql nvarchar(4000),
@paramlist nvarchar(4000)
if @spsir='1'
select @sql = @sql+ 'SELECT o.state_abbrv, count(o.state_abbrv) as kount FROM dbo.mortgage o left join dbo.Spanish s on o.per1_lname = s.lname'
select @sql=@sql+' WHERE 1 = 1'
SELECT @sql = @sql + ' group by o.state_abbrv ORDER BY o.state_abbrv '
here is the procedure:
create PROCEDURE search_orders_11
@SPSirvarchar(3)= null,
@debug bit = 0 AS
DECLARE @sql nvarchar(4000),
@paramlist nvarchar(4000)
if @spsir='1'
select @sql = @sql+ 'SELECT o.state_abbrv, count(o.state_abbrv) as kount FROM dbo.mortgage o left join dbo.Spanish s on o.per1_lname = s.lname'
select @sql=@sql+' WHERE 1 = 1'
SELECT @sql = @sql + ' group by o.state_abbrv ORDER BY o.state_abbrv '
here is the execution:
exec search_orders_11 @spsir=1
i get the whole command completed sucessfully, but no result. am i missing something here...
View 11 Replies
View Related
Apr 24, 2007
Hi,
I have to change collation for certain database. I think the only solution is to export or create through scripts the empty db structure (tables, PK & FK, defaults) and thereafter import data.
Since I don't have empty structure of this database I have to create somehow from the existing one which is with data, can somebody suggest how can I do this - take out the structure of the database from the db with data on it. I have 256 tables and I have to order them first with the dependencies of the tables?!
I will be really thankfull if somebody can help me on this issue.
Thnks,
sqlzagi
View 3 Replies
View Related
Nov 14, 2007
Is there any way to sort your results in a way that the empty results comes last? When I sort my recordset on a certain column I first get the empty values and the A, B, C etc. I would like to have it A, B, C, ..., Empty ones.
Regards
Ajmufic
View 6 Replies
View Related
Feb 11, 2008
I am trying to import Data from an Excel file to a SQL DB table. there are around 106 rows and 2 columns.
By default, the ssis is selecting around 200 columns and over 2000 rows. But all cells except for the 2 columns and 106 rows are empty. While I can specify that I need to read only 2 columns, I could not figure out a way to specify the rows. Any help?
View 3 Replies
View Related
Mar 13, 2008
I'm querying my database with a datetime constraint, only picking up records newer than the last ETL. Although I doubt it would ever happen I was going to put a check in the data flow to trap the case when NO rows were read due to inactivity in the OLAP. I set up a row count and tried to trap it. Apparently if you use an OLE DB source to get a result set and that result set is empty, the program flow bypasses everything and keeps running until it hits something causing an error, like an SQL Insert or Update command.
Is there any way to trap this condition? Currently it is going to cause the program to fail which will cause a snapshot restore (after kicking everyone out of the database).
Thanks.
View 8 Replies
View Related
Jul 22, 2007
Hello,
I have a query that returns the appropriate values I need, however there is one field I'd like to add and utilize but my problem is I only want to use it if it contains data.
If I filter it with IS NOT NULL it returns all the records, including the empty records. The field is simply empty, and doesn't come back as NULL. If I filter it with =' ' , it shows all the records with the empty records only.
I need to do the opposite, be able to filter it only if it's not empty.
Any help would be appreciated.
View 4 Replies
View Related
Nov 22, 2005
good day to everybody
View 5 Replies
View Related
Aug 23, 2006
Hi,
I have used Red Gates SQL bundle to make an identical db on sql2005 express from sql 2000. When i run my query against the sql2000 i get what I want, but when i run it against the sql2005, i get nothing.
Anyone got any suggestions to why?
web.config:
<!-- <add name="TPLConnectionString" connectionString="Data Source=[SQL2000],1433;Network Library=DBMSSOCN;Initial Catalog=TPL;User ID=??????;Password=????????;"
providerName="System.Data.SqlClient" />
-->
<add name="TPLConnectionString" connectionString="Data Source=[SQL2005]\SQLEXPRESS,1433;Integrated Security=true;Network Library=DBMSSOCN;Initial Catalog=TPL;User ID=?????;Password=???????;"
providerName="System.Data.SqlClient" />
default.aspx.cs
dbConnection.Open();
String ISPQuery = "SELECT STATEMENT";
SqlCommand command = new SqlCommand(ISPQuery, dbConnection);
SqlDataReader reader = command.ExecuteReader();
Please help!!!
Best regards
Terje Kristensen
View 2 Replies
View Related
May 16, 2007
I am creating three tables in a DataSet using three stored procedures and I need a way to know that either the tables have at least one row or preferably which if any has no rows. How can I do that?
using three SP's, one for each table:SqlCommand cmd = new SqlCommand("CompanyCheck", con);SqlCommand cmd2 = new SqlCommand("ContractorVerify", con);SqlCommand cmd3 = new SqlCommand("StoreLocation", con);
cmd.CommandType = CommandType.StoredProcedure; cmd2.CommandType = CommandType.StoredProcedure; cmd3.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@CompanyID", CompanyID); cmd2.Parameters.AddWithValue("@CompanyID", CompanyID); cmd3.Parameters.AddWithValue("@CompanyID", CompanyID); SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd; DataSet ds = new DataSet(); try { da.Fill(ds, "CompanyInfo"); da.SelectCommand = cmd2; da.Fill(ds, "ContractorInfo"); da.SelectCommand = cmd3; da.Fill(ds, "StoreInfo"); } catch { throw new ApplicationException("Data error"); } finally { con.Close(); }
Thank you
View 2 Replies
View Related
May 18, 2007
Hi,I wrote two queries to search in three tables mp_parent, mp_page and mp_parentThe first one is: SELECT mp_page.PID, mp_page.PageID, mp_page.PageContent, mp_page.ParID, mp_page.ChiID, mp_parent.ParentName FROM mp_page INNER JOIN mp_parent ON mp_page.ParID = mp_parent.ParentID The second one is:SELECT mp_page.PID, mp_page.PageID, mp_page.PageContent, mp_page.ParID, mp_page.ChiID, mp_child.ChildName FROM mp_page INNER JOIN mp_child ON mp_page.ChiID = mp_child.ChildID I used this way to display the records in a FormView public HttpContext context = HttpContext.Current; public void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { ViewState["srch"] = context.Items["srch"]; } FormView1.DataSource = GetTable(); FormView1.DataBind(); } private DataTable GetTable() { SqlConnection SqlCon = new SqlConnection("Data Source=AJ-166DCCD87;Initial Catalog=mp;Integrated Security=True;Pooling=False"); String SQL1 = "select mp_page.PID, mp_page.PageID, mp_page.PageContent, mp_page.ParID, mp_page.ChiID, mp_parent.ParentID, mp_parent.ParentName from mp_page INNER JOIN mp_parent ON mp_page.ParID = mp_parent.ParentID where PageContent like '%" + Convert.ToString(ViewState["srch"]) + "%'"; SqlDataAdapter Adptr = new SqlDataAdapter(SQL1, SqlCon); SqlCommandBuilder CB = new SqlCommandBuilder(Adptr); DataTable Dt = new DataTable(); Adptr.Fill(Dt); return Dt; SqlCon.Close(); } the question is how can I check if one record is empty to witch to another query ??Is it possible to know without using QueryString?Thank you
View 5 Replies
View Related
May 28, 2007
(Newbie). I'm trying to: 1) check if the SELECT command has returned any records, and 2) put a msg box on the screen if there are no records returned from the SELECT query. The type of code I'm heading towards is: (but it's wrong). Thank you in advance for your C# code suggestion.
protected void SqlDataSource1_Selected(object sender, SqlDataSourceStatusEventArgs e)
{if (SqlDataSource1.SelectParameters.Contains is "") then
MessageBox.show ("There are no records available") ;
}
View 8 Replies
View Related
Mar 9, 2004
Hi Friends,
I have one query that i have to Replace the Empty Value of a filed with some other value how can i do in SQL??
ID Phone Name
1 122 abc
2 xyz
3 444 mmm
4 525 ccc
5 nvb
Now i want replace the blank (Empty) filed with some charaters Numbers how can i do that?? any Help
Ashu
View 1 Replies
View Related
Aug 29, 2004
i have insert/update SQL sentence, but sometimes there are empty values because there not required in the database so sometimes the sql sentence look this way:
INSERT INTO EquipmentAndPlace (EquipmentID,EquipmentEmdaNo,EquipmentPlace,EquipmentIDForRecognize, EquipmentRemarks,EquipmentLastChecked) VALUES ('3','','2','1','','12/1')
with empty values, but then it doent update in the dataBase-only if all the values appear-
what the solution of it?
Thanks
View 4 Replies
View Related
Apr 17, 2005
I would like to exclude any parameter that is empty from the SELECT
command? How do I do this? This is part of a stored
procedure.
SELECT PersonID FROM Persons WHERE
(FirstName = @firstname) AND
(LastName = @lastname) AND
(SSN = @ssn) AND
(AddressID = @addressid) AND
(DOB = @dob) AND
(Middle = @middle)
THanks
View 2 Replies
View Related
Jul 11, 2001
example
create view v_GuestOrder
as
Select T1.id_Guest,T2.OrderName
from Guest T1
left join Order T2 T2.id_order = T1.Id_order
select * from v_GuestOrder
--
Id_Guest OrderName
-------- -----
1 spoon
2 phone
3
4 tv
I need something similar to
Select
id_Guest,
case orderName
when '' then Null -- Sql server gives error in thsi case
end as orderName
from v_GuestOrder
So I need to assign NULL to OrderName is query return empty string,
it will be treated by Crystal reports as Null
Please help , thanks
View 3 Replies
View Related