Viewing 15 posts - 7,336 through 7,350 (of 8,731 total)
If you're using 2012 (or 2005+) you should use TRY...CATCH
SET NOCOUNT ON;
DECLARE @sql NVARCHAR(101)='SELECT 1/0'
DECLARE @r Table (R INT)
DECLARE @T Table (Z INT)
BEGIN TRY
BEGIN TRANSACTION
INSERT INTO @r
EXECUTE...
December 16, 2013 at 4:30 pm
You need to add an additional ROW_NUMBER() instead of the previously generated n.
December 16, 2013 at 2:17 pm
I'm glad I could help. You made it easy. Thank you for taking the time of posting with all the details.
December 16, 2013 at 1:37 pm
Maybe I'm missing something but it seems that you're not using any column from table employee. You could remove it. If you need the information, I would join it out...
December 16, 2013 at 12:03 pm
I hope this will help you. You just need to complete the rest of the months with Copy-Paste-Replace.
WITH CTE AS(
SELECT TOP 12 DATEADD( mm, (ROW_NUMBER() OVER(ORDER BY(SELECT NULL)) -1) *...
December 16, 2013 at 11:36 am
Both queries are not equivalent. The first will return 10 rows and the second one will return 10 rows per EmpID.
December 16, 2013 at 11:06 am
There's not enough information to help you.
Please post DDL, sample data and expected results as explained on the article linked in my signature.
We're willing to help but we can't see...
December 16, 2013 at 10:55 am
The DDL and sample data were helpful. You could use the IFCode tags to avoid having a very large post and keep formatting but that's just style. 🙂
I got lost...
December 16, 2013 at 10:00 am
I'm not sure if this will help you but it sounds as if you need a calendar table (I used a CTE to get the needed months). I hope this...
December 16, 2013 at 9:43 am
There are several ways of doing that.
and ( @RoleID = 5
OR g.ID in
(Select ID From Groups where GroupName = 'SVP - LATAM'
Union ALL
Select ID From Groups where Sub =...
December 16, 2013 at 9:24 am
Maybe something like this might help.
Note that there's commented code that you might need to use to get the correct results.
CREATE TABLE ##Counts(
Table_Namenvarchar(128),
Whendate,
RecCount int --bigint
)
DECLARE @sql nvarchar(MAX)= ''
SELECT @sql =...
December 16, 2013 at 9:12 am
You just have to play with format codes 🙂
SELECT TOP 100
SUBSTRING( CONVERT(varchar,create_date,109), 13, 14) As CharTime
FROM sys.objects
REFERENCE: http://msdn.microsoft.com/en-us/library/ms187928.aspx
December 13, 2013 at 12:54 pm
It's easy to combine both techniques. Here's an example returning rows with 4 characters or less.
WITH E1(n) AS(
SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT...
December 12, 2013 at 2:03 pm
Good luck with your homework.
To get some help, feel free to read the article linked on my signature.
December 12, 2013 at 11:23 am
2 great articles by Jeff Moden on the subject:
December 12, 2013 at 10:34 am
Viewing 15 posts - 7,336 through 7,350 (of 8,731 total)