Saturday 15 March 2014

asp.net - C# and SQL Server 2005 -


I have 4 tables from which I am getting the records before the rows are required to meet with the internal rows, but the fourth With the table I need to add the left exterior because I must first preserve the rows received from the three tables

Now, the problem is that I want to leave with the fourth table, but This is only recorded = Thi should choose the date. I am passing the current date from C # while calling my stored procedure, but the point is that SQL Server is giving blank records.

Here is the query:

  Change the process (@SurrentDetected varchar (50)) Separate table 1 name. Name table2.class, table3.stream table1 from internal table 2 table 1.id = table2.id included in table 3 table3.id = left on table2.id on external table 4 table 4.id = table3.id And table4.date = @currentdate   

I used and with the external external join because I want to record in a way from where the clause filters the entire result and gives me a record .

Still, I used molding with both dates in the stored procedure but there is no positive feedback.

From C # I'm using

  var date = datetime.now.toshortdate (); Callstressprocessor (date)   

Please help me about this ASAP. First of all - You should use your appropriate type Dates - Thanks

DATETIME - Do not are inserted into wires and if you can avoid it! (And you can definitely escape it from here)

Second: Date code in the DATETIME as well as in the SQL server. Time is information, eg 2013-06-23 14:57:34 So if you're comparing a similarity to the status of your join, then only those lines that absolutely Your date matches more time will be selected. So you want to strip the part of the time, if you want to use just the dates for the comparison.

Then try this code here:

  ALTER PROCEDURE dbo.YourProcedureNameHere (@currentdate DATETIME) Choose Inter Table 1. Name, Table 2 Class, table 3 Dbo.table1 INNER from the stream join dbo.table2 table 1.id = table2.id INNER join dbo.table3 on table3.id = table2.id LEFT OUTER join table 4 table 4.id = table3.id and dateADD (day, DATEDIFF (Day, 0, Table 4 Detet), 0) = DATEADD (DAY, DATEDIFF (DAY, 0, @currentdate), 0)   

This is your table4.date < / Code> as well as remove the part of @currentdate and then compare just the date (no time involved). Once you upgrade to SQL Server 2008 or new, I would recommend using the code that is ready for it - only the date (no time). Unfortunately, this is not yet available in SQL Server 2005 .

In addition, from C # - use this line to call your stored procedure:

  var date = time of day. today; CallStoredProcedure (date);    

No comments:

Post a Comment