SQL Server Performance Forum – Threads Archive
T-SQL question
I’m quite new at T-SQL, and am having some problems. I hope it’s ok to post here asking for help – if not – just ignore this post. [<img src=’/community/emoticons/emotion-2.gif’ alt=’
1. Re-write as: INSERT INTO VACATION_REQUESTS (e_seid, fifo_date, day_off)
SELECT @SEID, @FIFO, * FROM TABLE
OR 2. I have a feeling the other data is dependant on the employee ID passed into the procedure. So include a WHERE clause in the SELECT.. INSERT INTO VACATION_REQUESTS (e_seid, fifo_date, day_off)
SELECT @SEID, @FIFO, * FROM TABLE WHERE…..
I would remove the star (*) and use the actual column name if I were in your situation. You are only getting one column back from the other table. Nathan H. Omukwenyi
MVP [SQL Server]
Fantastic, thanks for quick response – I’ll give it a go tomorrow. That was just a simple SELECT to demonstrate my quandry, the actual query I will be using is below. Assuming I can figure out how to make MINUS work in TSQL. –other variable not mentioned in other post
@sText varchar(8000) –delimted text of vacation dates
— split the requested vacation days
SELECT CAST(value AS SMALLDATETIME)
FROM dbo.fn_Split(@sText, ‘,’)
— subtract out any that already exist
MINUS
SELECT [day_off]
FROM dbo.VACATION_REQUESTS
WHERE @seid = e_seid
If your using SQL Server 2005 , you would replace ‘MINUS’ with ‘EXCEPT’. With SQL Server 2000 you can use the ‘NOT IN’ operator to prune the results: SELECT CAST(value AS SMALLDATETIME) FROM dbo.fn_Split(@sText, ‘,’)
WHERE CAST(value AS SMALLDATETIME) NOT IN
(SELECT [day_off]FROM dbo.VACATION_REQUESTS WHERE @seid = e_seid) Nathan H. Omukwenyi
MVP [SQL Server]
Works perfectly. Thanks so much vbkenya. Really appreciate it – you saved me hours of googling and experimenting.
Also refer this
http://vyaskn.tripod.com/oracle_sql_server_differences_equivalents.htm Madhivanan Failing to plan is Planning to fail
If your using SQL Server 2005 , you would replace ‘MINUS’ with ‘EXCEPT’. With SQL Server 2000 you can use the ‘NOT IN’ operator to prune the results:
———————————————–
yes
]]>