Viewing 15 posts - 16 through 30 (of 54 total)
GETDATE() is just a function that returns today's date, as an example datetime.
You would substitute your date column names
SELECT CAST(CONVERT(VARCHAR(10), StartDate, 120) + ' 12:00:00' AS DATETIME)
If you only need...
October 1, 2012 at 2:06 am
The standard way of doing these casts is to go via varchar and back to datetime, truncating any data not required
e.g.
SELECT CONVERT(VARCHAR(10), GETDATE(), 120) -- get date as...
October 1, 2012 at 1:52 am
Yes dynamic SQL would seem appropriate.
Basically you create your entire SQL Statement in a string then call EXEC on it.
e.g.
DECLARE @sql Varchar(MAX);
DECLARE @TODAY Varchar(10);
SELECT @TODAY = CONVERT( VARCHAR(10),GETDATE(),...
September 25, 2012 at 2:54 am
I'm sure there would be a way of passing the required dates as a variable to the stored procedures., or, if it is always the current date, why not...
September 25, 2012 at 1:28 am
First time I've looked at one of these puzzles. Managed to tie up my cpu for ages generating useless batches of permutations and combinations. No result yet. ...
September 18, 2012 at 9:49 am
GSquared (9/14/2012)
Partial recompile.Statement-level, not proc-level.
Example here: http://sqlserverplanet.com/sql-optimization/temp-table-recompiles/
Excellent article on table variables and temp tables and other options: http://www.simple-talk.com/sql/t-sql-programming/temporary-tables-in-sql-server/
Thanks: very useful information. 🙂
September 14, 2012 at 8:20 am
SELECT a column from your table, then put it into the @Variable in the FETCH Statement.
Here is a full example.
CREATE TABLE #Tmp (
i INT IDENTITY(1,1),
val VARCHAR(50) );
INSERT INTO #Tmp (val)
SELECT...
September 14, 2012 at 8:13 am
Depends what you need.
#Temporary tables can only be accessed by the instance of stored procedure that is running. If two instances of the stored proc are running they each...
September 14, 2012 at 6:10 am
Be aware that cursors are not always the best way of doing things.
Here is the standard cursor code. Promise not to abuse it 😉
DECLARE @i INT;
DECLARE @COUNT...
September 14, 2012 at 3:51 am
I got it right only because I was expecting a trick question. 😀
September 14, 2012 at 1:38 am
UNIQUE is optional, so omit that if empno has duplicates.
But if empno has duplication, then isn't it a complete duplicate row (same firstname/middlename/lastname too)
September 13, 2012 at 10:15 am
BeginnerBug (9/13/2012)
September 13, 2012 at 10:01 am
Yes you can create a clustered index on a #Tmp table.
The syntax is exactly the same as for a normal table.
CREATE [UNIQUE] CLUSTERED INDEX CIX_Tmp_EmpNo ON #emp(empno)
Since empno is used...
September 13, 2012 at 6:50 am
See CAST AND CONVERT http://msdn.microsoft.com/en-us/library/ms187928(v=sql.105).aspx
There are loads of date formats available, though you may have to truncate the time portion.
You need something like
SELECT CONVERT(e.expiration_date, varchar(11), 130) AS Expiration_Date;
September 13, 2012 at 4:51 am
Ali Tailor (2/17/2011)
I just passed the MCTS exam 70-432 with 833 marks, I just want to Know that may I use the MCTS Logo on Resume if yes, in...
September 13, 2012 at 1:52 am
Viewing 15 posts - 16 through 30 (of 54 total)