Viewing 15 posts - 1 through 15 (of 35 total)
Can you post some sample data?
January 3, 2012 at 10:47 pm
DECLARE @Employee Table
(code VARCHAR(50),name VARCHAR(50))
INSERT INTO @Employee
SELECT '001','A' UNION ALL
SELECT '002','B' UNION ALL
SELECT '003','C'
DECLARE @Position Table
(JobCode VARCHAR(50),JobTitle VARCHAR(50),EmployeeCode VARCHAR(50),
FromDate DATETIME
)
INSERT INTO @Position
SELECT 'MRE','abc','001','2011/09/09' UNION ALL
SELECT 'MRO','abcd','001','2011/10/10'UNION ALL
SELECT 'CEO','xy','002','2012/01/01' UNION...
January 2, 2012 at 11:19 pm
DECLARE @TableO TABLE
(UserName VARCHAR(100),[DateTime] DATETIME,[Action] VARCHAR(50))
INSERT INTO @TableO
SELECT 'abc','2011-01-22 23:45','xyz' UNION ALL
SELECT 'abc','2011-01-23 10:00','pqr' UNION ALL
SELECT 'abc','2011-01-24 10:00','pqr' UNION ALL
SELECT 'dtr','2011-01-24 10:00','pqr' UNION ALL
SELECT 'abc','2011-01-25 10:00','pqr' UNION ALL
SELECT 'abc','2011-01-26 10:00','pqr'...
December 29, 2011 at 2:33 am
If it is fixed pattern it should work for you.
DECLARE @STR VARCHAR(100)
SET @STR = '12345 0047225P1'
SELECT SUBSTRING(@Str,CHARINDEX(' ',@Str)+1,7) AS ID,
SUBSTRING(@Str,CHARINDEX(' ',@Str)+8,1) AS 'Account No'
December 29, 2011 at 2:14 am
You can try this:
;WITH CTE AS
(
SELECT Number,Type,Name,ROW_NUMBER() OVER(PARTITION BY Type ORDER BY Type) As 'Pos' FROM RelationshipTable
)
SELECT Number,Type,Name FROM CTE
WHERE
Pos = 1
December 1, 2011 at 12:11 pm
Hi,
You can change your Where condition.
SELECT *
FROM midyearexample
WHERE
startdate < '1985-07-15' AND (enddate > '1985-07-15' OR enddate IS Null)
November 26, 2011 at 3:02 am
Check this one.
ALTER FUNCTION dbo.RemoveNonNumericCharacters (@Temp VARCHAR(1000))
RETURNS VARCHAR(1000)
AS
BEGIN
While PatIndex('%[^0-9,.]%', @Temp) > 0
Set @Temp = Stuff(@Temp, PatIndex('%[^0-9,.]%', @Temp), 1,...
October 18, 2011 at 3:05 am
Hi,
Try to write your T-SQL as below.
DECLARE @TABLE1 NVARCHAR(30)
DECLARE @TABLE2 NVARCHAR(30)
DECLARE @SQL NVARCHAR(1000)
SET @TABLE1 = 'dbo.City'
SET @TABLE2 = 'dbo.Marks'
SET @SQL = N'SELECT * FROM '+@TABLE1+';'+'SELECT * FROM...
October 5, 2011 at 4:15 am
October 4, 2011 at 3:40 am
Hi,
You can try this one.
DECLARE @test-2 TABLE
(A INT,B INT,C INT)
INSERT INTO @test-2
SELECT 10,1,1
UNION ALL
SELECT 10,1,2
UNION ALL
SELECT 10,2,1
UNION ALL
SELECT 10,2,2
UNION ALL
SELECT 10,3,1
UNION ALL
SELECT 10,3,2
UNION ALL
SELECT 11,1,1
UNION...
September 29, 2011 at 3:35 am
Hi,
Try this T-SQL.
DECLARE @ID1 VARCHAR(7)
DECLARE @ID2 VARCHAR(7)
SET @ID1 = '1234'
SET @ID2 = '76541'
SELECT RIGHT('0000000'+@ID1,7)+RIGHT('0000000'+@ID2,7)
September 29, 2011 at 3:14 am
Hi,
You can use Substring function here.
In which field you are storing date ?
Make it clear i will try to write query.
September 28, 2011 at 3:57 am
nhimabindhu (9/21/2011)
How to find the file name in the folder if it exists or not.Daily text file is coming in the format ex:21-09-2011 i...
September 21, 2011 at 4:16 am
Viewing 15 posts - 1 through 15 (of 35 total)