|
Does it have an ID column and do some gues work.
|
|
|
|
|
Hi the follwing procedure i am getting a month all dates...,
In that i am using my own query for the select statement place...,
I used left outer join to show all the dates of @tbl_date...,
But it's displaying only What are the dates i am having in tblMonthhourdetails table those dates only...,
But i want to display all the dates of that month and if the @tbl_date table dates and tbltimecardmain and tblmonthhourdetails dates are matchable those records also want to display...,
Else if there's is no matachable date in that timecardmain table and month hour details table those date place it want to show null...,
I pasted my query on here,
I tried with all joins but i didnt get answer...,
Plz hlp me how to do that...,
Stored procedure:
DECLARE @startDate datetime
declare @nextdate datetime
DECLARE @endDate datetime
declare @tbl_date table (mydate datetime)
set nocount on
SET @startDate = CAST( CAST( 2007 AS varchar(4) ) + '0101' AS datetime )
SET @startDate = DATEADD( m, 6 - 1, @startDate )
set @enddate=dateadd(m,1,@startdate)
while @startdate < @enddate
begin
--SET @nextdate = DATEADD( d, 0, @startdate )
insert into @tbl_date values (@startdate)
set @startdate=dateadd(d,1,@startdate)
end
SELECT EM.empId as EId, EM.empName as EName,ttd.mydate,
TC.shift,PM.location,TC.reportingtime as FromTime, TC.leavingtime as ToTime,
MHD.AppWHours as Reg,MHD.AppOtHours as Ot,MHD.AppSHours as SReg,
MHD.AppSOtHours as SOt,SD.Whrs
FROM dbo.tblEmployeeMaster EM INNER JOIN dbo.tblTimeCardmain TC ON EM.empId = TC.empid
left outer join @tbl_date ttd on ttd.mydate=TC.carddate
left outer JOIN dbo.tblMonthHourDetails MHD ON (ttd.mydate = MHD.SDate
and TC.empid = MHD.EmpId)
--order by EM.empid,ttd.mydate
INNER JOIN dbo.tblProjectMaster PM ON TC.projectid = PM.projectID
INNER JOIN dbo.tblsalarydetails SD ON MHD.EmpId = SD.EmpID
where EM.empid=213 and datepart(mm,Ttd.mydate)=6 and
datepart(yyyy,ttd.mydate)=2007
order by ttd.mydate
Regards,
Magi
|
|
|
|
|
Hi Magi
I think what you want is:
FROM @tbl_date ttd
LEFT OUTER JOIN dbo.tblTimeCardmain TC
ON TC.carddate = ttd.mydate
LEFT OUTER JOIN dbo.tblEmployeeMaster EM
ON EM.empId = TC.empid
LEFT OUTER JOIN dbo.tblsalarydetails SD
ON SD.EmpID = TC.empid
LEFT OUTER JOIN dbo.tblProjectMaster PM
ON PM.projectID = TC.projectid
LEFT OUTER JOIN dbo.tblMonthHourDetails MHD
ON MHD.EmpId = TC.empid
AND MHD.SDate = TC.carddate Your @tbl_date table is the lead-table in the query. The rest of the tables should be outer-joined as they contain the optional data.
Regards
Andy
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message".
|
|
|
|
|
NO andy Still i didnt get answer...,
Now also its displaying what are dates i am having in my tblmonthhourdetails those records only...,
But i need the @tbl_date all dates ,
and if that date and tblcardmain and tblmonthourdetails dates are matchable those records,
other remaining dates place it want to show null...,
Regards,
Magi
|
|
|
|
|
hi all
i'm making database using sql server 2000 and want to connect this database with an application desinged using visual basic6
|
|
|
|
|
I'm sorry, but what's the question? You've stated an intent only. Do you mean how do I do this? If so, I would suggest that you will want to use ADO.
|
|
|
|
|
Well if you want to know what the connection string is, this is the only place for all your connectionstrings : http://www.connectionstrings.com/[^].
Otherwise, please give more information in your question as it is too common.
|
|
|
|
|
hi dere....
i'm not able to create table in sql server 2005 from another table...i know this thing in sql plus in oracle....but i'm not able to construct in sql server 2000
Ashish Vohra
|
|
|
|
|
I am not sure exactly what you mean, could you please clarify your exact requirement?
|
|
|
|
|
SELECT * INTO NewTable FROM OldTable
|
|
|
|
|
SELECT * INTO <newtbl from="" <oldtbl="">
This creates a copy of <oldtbl> to <newtbl>
INSERT INTO <tablea> (<col1>, <col2>) SELECT <col1>, <col2> FROM <tableb>
Inserts rows fetched by select statement into <tablea>
Regards
KP
|
|
|
|
|
How to write script to take backup or restore database(when i run a prticular file it automatically backup or restore database)
|
|
|
|
|
http://www.google.com[^] around for it.
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
Hi,
I have faced a problem while inserting data into the sql server 2000.
First I have made a database and related Store procedure in SQL Server 2005.
When I run a store procedure in SQL Server 2005, it works fine.
But I have generated SQL script from SQL Server 2005 and run in Server 2000 (after some changes in script).
Tables and store procedure are created in SQL Server 2000. Then I made a database user and allow it all permissions (Set this user as dbo).
When I insert data into the sql server 2000 table it runs the store procedure but no insertion will take place
|
|
|
|
|
May I see the full script with storred procedure which you have ran on sql server 2000 db
|
|
|
|
|
Hi,
MSSQL 2005, I want to delete blobs on a regular basisto preserve diskspace.
The blobs has various meta-data but I want to delete them based on time of
creation (date-time) and type. My concern is to equally disperse the deletion
so no type ends up being empty, but rather delete a few of this type and some
in that type ... and so on.
Any kind of help regarding this would be appriciated.
This CTE takes 100 from every Category
WITH tempdata AS (SELECT ROW_NUMBER() OVER (PARTITION BY Category<br />
ORDER BY Age DESC) AS rownum, ID FROM Imageblob)<br />
DELETE FROM tempdata WHERE rownum > 1000;
But how do i use it with a grouping selection so I can choose
to delete from the category with the most rows.
Select count(Age)<br />
From imageblobs<br />
Group by Catebogry
that gives me each row per category but I want to use it with the first CTE
and also order them.
Any suggestions/code/help/hints are much appritiated´
My t-sql knowledge is rubbish
Cheers,
/Andreas
-- modified at 12:27 Monday 9th July, 2007
|
|
|
|
|
Hi, all!
I have the following problem.
I have an application in vb 2005 and a database in SQL server 2000. The instance of SQL server is installed on one machine in the network, however the application should work on several machines within this network.
The question is do I need to have separate instances of Sql server on each of the machines with the same database attached, or I need to connect to a single SQL server, in that case what will be the connection string? The name of the computer in the network and name of the server, or only the name of the server?
Could you please suggest me the sample connection string, I should use in my case.
Thanks beforehand,
D.
|
|
|
|
|
You don't need to install sql server 2000 instance on each and every system.
just install it on one system in the lan or workgroup
and in your query string give the name of that system
for example i had installed the sql on "test" system so the query string will be
"Server=test;Database=your_db_name;uid=sa;"
if u have a password for sa account then also include it.
|
|
|
|
|
Hi i am using one procedure to get a month all dates...,
But each and every dates creating separate,separate column name...,
But i want display those all dates under come in same column name...,
Means:
when i execute my procedure i am getting o/p like:
Startdate
2007-06-01
Startdate
2007-06-02
startdate
2007-06-03
.
.
.
startdate
2007-06-30
But i want following format:
Startdate
2007-06-01
2007-06-02
.
.
.
2007-06-30
This is the procedure:
DECLARE @startDate datetime
declare @nextdate datetime
DECLARE @endDate datetime
SET @startDate = CAST( CAST( 2007 AS varchar(4) ) + '0101' AS datetime )
SET @startDate = DATEADD( m, 6 - 1, @startDate )
set @enddate=dateadd(m,1,@startdate)
set @enddate=dateadd(d,-1,@enddate)
select @startdate as startdate
while @startdate < @enddate
begin
SET @nextdate = DATEADD( d, 0, @startdate )
set @startdate=dateadd(d,1,@nextdate)
select @startdate as startdate
end
Advance Thanks,
Regards,
Magi
|
|
|
|
|
Please - don't repost variants of the same question. You've been given all the information you need to have a go at answering this yourself. See my answer from earlier today as a basis.
|
|
|
|
|
Ya i didnt see that...,
Anyway thanks for ur post...,
Keep in touch
Regards,
Magi
|
|
|
|
|
|
How can i export or import tables and objects from one database to another in Microsoft SQL Server Management Studio Express 2005.
Best Regards,
M. J. Jaya Chitra
|
|
|
|
|
Hi
Right click on the database ... click Tasks -> Emport / Import Data.
For more information, check this link
Exporting and Importing[^]
Harini
|
|
|
|
|
I am a beginner here for ASP.NET. I can't manage to insert data using ASP.NET. I have successful using the same connection string to do SELECT statement,but I'm wondering how to do INSERT statement to MySQL database. Please give me some solution here.
This is my code:
Imports System.Data.Odbc
Dim strConnString As String = "Driver={MySQL ODBC 3.51 Driver};Server=localhost;option=3;Database=MyDatabase;Uid=root;Pwd=Pass;"
Dim ObjConn As New OdbcConnection(strConnString)
Dim ObjRead As OdbcDataReader
Dim ObjComm As OdbcCommand
Try
ObjComm = New OdbcCommand("INSERT INTO member_1(Member_ID,Username,Gender,Email,Contact_No,Address,Password)VALUES('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & TextBox6.Text & "','" & TextBox7.Text & "'", ObjConn)
If (TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Or TextBox4.Text = "" Or TextBox5.Text = "" Or TextBox6.Text = "" Or TextBox7.Text = "") Then
Else
ObjConn.Open()
ObjComm.ExecuteNonQuery()
ObjConn.Close()
End If
Catch ex As Exception
Console.WriteLine(e.ToString())
End Try
Anyone can give me some solution here?
Thank you for readings.
Regards
Drex
|
|
|
|
|