Viewing 15 posts - 196 through 210 (of 761 total)
dwain.c (8/24/2012)
Since row ordering is not guaranteed by SQL, how do you know you're subtracting the right numbers at each row?
Yes it should be ordered according to the OP's requirement....
August 24, 2012 at 5:31 am
You can do it as follows:
--Creating Tables
Create table Ex
(Value int )
Create Table Ex1
(Value int )
--Inserting Sample Data
Insert Into Ex
Select 1
Union ALL
Select 2
Union ALL
Select 3
Union ALL
Select 4
Union ALL
Select 5
Insert Into Ex1
Select...
August 23, 2012 at 11:40 pm
You can do it as follows:
--Creating Tables
Create Table Ex
(TargetId int )
Create Table Ex1
(QID int )
Create Table Ex2
(KitId int,
Targetid int,
QId int )
--Inserting Sample Data
Insert into Ex
Select 100
Union...
August 22, 2012 at 11:11 pm
This would work in all cases I suppose:
Declare @string Varchar(max) = 'ertgfh_fert_dfgt_ghty'
Select SubString(@string, (CHARINDEX('_', @string, 0) + 1),
(CharIndex('_', RIGHT(@string, (LEN(@string) - (CharIndex('_', @string, 0)))), 0) - 1)) As NewString
August 22, 2012 at 10:14 pm
Try this:
Select SubString('abc_def_cet_qwe', (CHARINDEX('_', 'abc_def_cet_qwe', 0) + 1), 3) As NewString
If the length is not fixed then you can use this approach:
Select SubString('abc_def_cet_qwe', (CHARINDEX('_', 'abc_def_cet_qwe', 0) + 1),
(CharIndex('_', RIGHT('abc_def_cet_qwe',...
August 21, 2012 at 11:02 pm
raghuldrag (8/17/2012)
ya its workin..... suppose i need the particular top 3rd postion of max salary means how to modify
Declare @position Varchar(30)
Set @position = 'sales'
Select Top 1 * From
...
August 17, 2012 at 5:16 am
SomewhereSomehow (8/17/2012)
vinu512 (8/17/2012)
Declare @position Char(33)
Set @position = 'sales'
Select ename, job From
(
Select *, ROW_NUMBER() Over (Partition By job Order By Sal) As rn From...
August 17, 2012 at 3:53 am
dwain.c (8/17/2012)
Look at BOL: http://msdn.microsoft.com/en-us/library/ms188001(v=sql.105).aspxDoes the first example on that page do what you want?
If not, perhaps I'm misunderstanding.
Yes, that's the article I read to start with this. I was...
August 17, 2012 at 3:50 am
From what I understand, this should do it:
Declare @position Char(33)
Set @position = 'sales'
Select ename, job From
(
Select *, ROW_NUMBER() Over (Partition By job Order By Sal) As rn From Ex
)...
August 17, 2012 at 1:14 am
This is on the same lines but a little different in logic:
Select LEFT([Flammables/solvents], (CHARINDEX('/', [Flammables/solvents]) - 1) ) As Flammables,
RIGHT([Flammables/solvents], (CHARINDEX('/', Reverse([Flammables/solvents])) - 1) ) As...
August 17, 2012 at 12:44 am
The solution is fine...but with so many Cast and Parsename function calls, I think that if you are working on a big table with lots of data then the performance...
August 15, 2012 at 9:57 pm
Thanks for all the help guys. I think I should rather handle the formatting at the Application Level. 🙂
August 8, 2012 at 10:03 pm
Jeff Moden (8/6/2012)
vinu512 (8/4/2012)
August 8, 2012 at 1:18 am
dwain.c (8/6/2012)
vinu512 (8/6/2012)
dwain.c (8/6/2012)
SomewhereSomehow (8/3/2012)
August 6, 2012 at 10:35 pm
calvo (8/6/2012)
what is the collation and data type of the field storing the current date?
Collation: SQL_Latin1_General_CP1_CI_AS
DataType: DateTime
GSquared (8/6/2012)
August 6, 2012 at 10:32 pm
Viewing 15 posts - 196 through 210 (of 761 total)