|
|
Hi everyone,
I have a table with the name is: Detail, that includes 'DateOfBirth' column (datetime type). For example: 1986-06-16 00:00:00.000
Now I want to create a store procedure to swap "day" value and "month" value for date values that have "day" and "month" value smaller 13, such as :
Origin value: 1984-05-10 (10th May)
Expected value: 1984-10-05 (5th Oct)
Do you know how can do that ?
Thanks and regards,
Tai
|
|
|
|
|
This is not tested and it is not the only way to do this:
UPDATE MYTABLE
SET DOB = CAST(CAST(YEAR(DOB) AS VARCHAR(4)) +
CAST(DAY(DOB) AS VARCHAR(2)) +
CAST(MONTH(DOB)AS VARCHAR(2)) AS DATETIME) +
CAST(DOB AS TIME)
|
|
|
|
|
Thank you.
I got an error when trying your code:
"Type TIME is not a defined system type"
I am using Microsoft SQL Server
|
|
|
|
|
I use TIME with SQL2008. You can use the CONVERT command to give you the time portion of the DATETIME column as a VARCHAR. (Look at 108)
|
|
|
|
|
taibc wrote: Do you know how can do that ?
Using string-manipulation functions. The problem here is not the format of your date, but the fact that it's stored as a string, not as a date.
What are you going to do with the date "6 may"? Would that become "5 juli", or are you going to "hope" that it is the correct date (that's what you state; you'd like to skip those)?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thank you.
Yes, my expected result is 5 June.
I am not good with fuctions in sql, do you have any ideas ?
Kind regards,
|
|
|
|
|
taibc wrote: Yes, my expected result is 5 June.
That's not what you stated in your original question; take a look, you wanted only those where you could "invalidate" the date by having a "day" larger then the number of months. 5 may would be skipped if you do it like that.
taibc wrote: I am not good with fuctions in sql, do you have any ideas ?
Convert it to a date-column, as it should have been. It's either that, or trying your luck at string-manipulation. You'll have to write the code yourself btw, I'm not going to.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hello to all,
I'm new to this forum and a few days ago I started to learn web design.
I have a porjet to start in September and I am looking to make effective technical.
I have to send daily sms to customers and I diffenrents around 25,000 customers each with 25,000 different phone numbers and different addresses.
My socui is to do all this from a website.
I want to send emails to smss and internet party.
I will create a database and sales agents will charge to send the data by group. Chauqe day I have to meet about 20 000 people.
So my problem is what solution I need? I mean how to make it be effective?
- I want my system to be independent, I do not want to depend on a GSM operator here, it will not be possible given the daily flow and no operator still offers unlimited sms offers here (I am in West Africa ).
- I would like for example to specify the sender according to the groups of my clients.
I am ready to buy equipment, I made a few searches on the net and I saw devices like sms gateway but I do not know how these devices work.
Is it possible to do this with php? and be totally independent?
Is there a solution where I can use the services of an operator in Europe or Canada or state States?
I want my system to be truly independent as far as possible.
What equipment do I need?
How to proceed?
I hope I have your good detailed answers.
|
|
|
|
|
Hi,
I have an SSIS package which does some Database functionalities, I want to deploy that package as just .dtsx file on to some servers filesystem and call it from a schduled task.
Can I just copy the .dtsx file from the solution folder and put it on some server and execute it from .Net code.
If not how to deploy an SSIS package on to filesystem as just .dtsx file and call it from .net code to finish its functionalities.
I am also searching on the internet but any kind help like code snippet, suggestion or any link would be appreciated.
Thanks in advance.
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
|
What is it with you people today, the previous bloke wanted to use a trigger, you want to deploy a dtx and schedule it with some tool. USE A SQL JOB. That is precisely what it is designed for! there are a whole bunch of stuff available [^]
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi. I am creating an application that uses sqlserver and asp.net c#. I need to create a trigger that inserts data into a table 30 days before an expiry date field in another table. I have created the trigger but dont know how to implement the dates? Any suggestions would be appreciated.
|
|
|
|
|
Does the date go in when the "expiry date" column is populate or do you want it to go in 30 days before the date?
|
|
|
|
|
What you are describing is not a trigger spit but a JOB, the job would call a proc that checks for expiry dates 30 days away and insert the appropriate record. You would schedule the JOB to run daily.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
thanks for the reply. I had a feeling a trigger would be difficult or impossible to implement in this way.. Not sure how to create this job tho. Any pointers would be appreciated?
|
|
|
|
|
I already have a table with an appointment date entered. I need to update another table 30 days before before this appointment date. Thanks
|
|
|
|
|
Create a stored procedure that does the following
Get the expiring records
insert the relevant data into the target table.
In SSMS create a Job that calls the stored proc
schedule the job to run every day
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
thanks I'll give it a try!
|
|
|
|
|
I am new to ssis. I Created on pakcage which loops excel fils(.xls) of one folder and extracts to database.
I placed Excel files in one folder (like C:\Documents and Settings\username\My Documents\Temp). The Sqlserver2005 server located on another machine (where i need to dump the data from excel to this destination server.)
I am running package on my local machine. When i run it is giving below error at Excel Source of Data Flow task.
SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER. The AcquireConnection method call to the connection manager "Excel" failed with error code 0xC0202009.
Please help me out.
Thanks,
Ravikiran
|
|
|
|
|
My usual attempt to resolve a sql error is to drop the error message into google[^] - seems like it is a common problem.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi All,
In DB2, i have used XMLAGG built in function in order to convert Rows to Column String Concatenation. Since lot of records are available in the table, performance wise it was too slow. Whether any user defined function is available for DB2 for string concatenation.
Thanks in Advance.
|
|
|
|
|
EmpID Leave_Year Taken Credit Balance
435 2014 0 22 22
435 2013 10 22 12
435 2012 24 22 0
435 2011 20 22 2
435 2010 23 22 0
435 2009 21 22 1
I want to Update this table Balance column value with the Next row Balance column value
eg: Leave_Year 2011, Balance value (2) Update with Leave_Year 2012 Balance Value (0)
0 - 2 = -2 should get in 2011 Balance column, use with this where condition, where Next row (2012) Taken>0
How to write Update sql for this
|
|
|
|
|
Can you explain more in details your case?
I Love T-SQL
"VB.NET is developed with C#.NET"
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
Hi,
Check the Script
SELECT M.ID,(ROW_NUMBER() OVER(PARTITION BY M.EmpID ORDER BY M.EmpID)) 'RowNumber', M.EmpID, M.Leave_Year, M.Taken, M.Credit,
(SELECT SUM((ISNULL(Balance,0.0))
FROM Table_Name WHERE ID<=M.ID AND EmpID=M.EmpID)
FROM Table_Name M
ORDER BY M.EmpID
|
|
|
|