Forum: MS SQL Aug 25th, 2009 |
| Replies: 9 Views: 7,855 May be this SQL can solve this problem:
create table #tmpT (ABC char(1))
insert #tmpT
select 'A' union all
select 'B' union all
select 'C' union all
select 'D' union all
select... |
Forum: MS SQL Jul 29th, 2009 |
| Replies: 2 Views: 604 maybe you can use CASE ... WHEN ... END command like below:
select cast(case when exists (SELECT * FROM UserList WHERE UserName = 'Tester') then 1 else 0 end as bit) |
Forum: MS SQL Dec 27th, 2008 |
| Replies: 3 Views: 3,731 Try this query below:
SELECT 'Testing' as [Title] , [MONEY1] , [MONEY2]
from (SELECT sum(Total) AS [MONEY1] FROM((SELECT SUM(T1.Amount+T2.Amount) AS Total FROM TABLE1 T1 INNER TABLE2 T2 ON... |
Forum: MS SQL Dec 27th, 2008 |
| Replies: 3 Views: 1,050 Make it subquery like below:
select [Year], [Month], sum([Benefits Rating]) as [Benefits Rating], sum([Facilities Rating]) as [Facilities Rating]
from (...... your origin query ......) X
... |
Forum: MS SQL Dec 22nd, 2008 |
| Replies: 1 Views: 718 You cannot use just select command.
You must use cursor to list the time list.
Try and modify code below:
set nocount on
declare @CounterDate smalldatetime,
@MaxDate smalldatetime
create... |
Forum: MS SQL Dec 3rd, 2008 |
| Replies: 1 Views: 349 You can use table master.dbo.sysprocesses.
This system table contain connected users. |
Forum: MS SQL Nov 24th, 2008 |
| Replies: 3 Views: 854 Try this command:
select T1.idx, T2.idy, T2.u
from Table1 T1 right join Table2 T2 on
T1.idy = T2.Idy and T1.idx = 'one' |
Forum: MS SQL Nov 19th, 2008 |
| Replies: 4 Views: 621 change your command into:
select *
from (Select table_name
from information_schema.tables
where table_name= @table_name
) AliasName
change your... |
Forum: MS SQL Nov 15th, 2008 |
| Replies: 5 Views: 1,412 Use this command
select sum(Total) as [Amount]
from
(
select T1.Amount+T2.Amount as Total From TABLE1 T1 INNER TABLE2 T2 ON T1.ID = T2.ID
union all
select Amount as Total... |
Forum: MS SQL Nov 13th, 2008 |
| Replies: 5 Views: 1,412 select sum(Total)
from
(
select T1.Amount+T2.Amount as Total From TABLE1 T1 INNER TABLE2 T2 ON T1.ID = T2.ID
union all
select Amount as Total FROM TABLE3
) X |
Forum: MS SQL Oct 12th, 2008 |
| Replies: 1 Views: 1,007 Try this code below:
select 1 as Col1, 'MT' as Col2, 30 as Col3, 'UK' as Col4, 0 as Col5, 70 as Col6, 'FR' as Col7
into #tmpX
union all
select 2 as Col1, 'SM' as Col2, 30 as Col3, 'IL' as... |
Forum: MS SQL Oct 11th, 2008 |
| Replies: 1 Views: 691 Try this code below:
select top 1 *
from (select top 6 *
from #tmpSalary
order by Salary) X
order by Salary desc |
Forum: MS SQL Oct 11th, 2008 |
| Replies: 1 Views: 645 Try code below:
declare @Ask varchar(255)
select @Ask = '100.100.2225.104'
create table #tmpAddr (
Addr varchar(255),
Inc int) |
Forum: MS SQL Oct 11th, 2008 |
| Replies: 1 Views: 1,342 Change your Select check to:
charindex(' ' + uzip + ' ',' ' + 'S10 S11 S7 S17 S8 S3 S30' + ' ') > 0
This code will check 'S1' <> 'S10' |
Forum: MS SQL Sep 6th, 2008 |
| Replies: 1 Views: 1,615 Try this code below:
select *
from #tmpX X inner join (select A, B from #tmpX group by A, B having count(*) > 1) Y on
X.A = Y.A and X.B = Y.B |
Forum: MS SQL Sep 6th, 2008 |
| Replies: 8 Views: 2,421 Try this one:
select completed
from table
order by case when completed is null then 0 else 1 end, completed desc |
Forum: MS SQL Aug 26th, 2008 |
| Replies: 4 Views: 889 You can combine your 2 query with 'UNION ALL' or 'UNION' like below:
SELECT * FROM TBL_Modules WHERE identifier IN ('1','2','3','4','5','6') ORDER BY Identifier
union all
SELECT m.* FROM... |
Forum: MS SQL Aug 25th, 2008 |
| Replies: 2 Views: 1,588 select * from tb_TableName where AColumn like 'user1%' |
Forum: MS SQL Jun 9th, 2008 |
| Replies: 1 Views: 2,662 create table #tmp (Code varchar(255), Price money, Date smalldatetime)
insert #tmp (Code, Price, Date)
select 'ProductA', 12.00, '12/10/2002' union all
select 'ProductA', 12.50, '01/15/2005'... |
Forum: MS SQL Jun 9th, 2008 |
| Replies: 5 Views: 4,162 create table #tmp (Code varchar(255), Price money, Date smalldatetime)
insert #tmp (Code, Price, Date)
select 'ProductA', 12.00, '12/10/2002' union all
select 'ProductA', 12.50, '01/15/2005'... |
Forum: MS SQL Jun 3rd, 2008 |
| Replies: 1 Views: 1,261 Try this code.
SELECT DISTINCT
COALESCE (s3.ADM_CODE, s1.ADM_CODE) AS Expr1, COALESCE (s3.FULLNAME, COALESCE (COALESCE (CASE s2.shortform WHEN '' THEN NULL
... |
Forum: MS SQL May 12th, 2008 |
| Replies: 6 Views: 1,387 Try this code
select c.name, isNull(doc_A.Doc_A, 0) as Doc_A, isNull(doc_B.Doc_B, 0) as Doc_B, isNull(doc_C.Doc_C, 0) as Doc_C, isNull(doc_D.Doc_D, 0) as Doc_D
from tUsers u inner join... |
Forum: MS SQL May 9th, 2008 |
| Replies: 2 Views: 5,622 You cannot increase this limit. You must change your program. See http://www.daniweb.com/forums/thread114466.html. Hope this link can give you some idea. |
Forum: MS SQL May 1st, 2008 |
| Replies: 1 Views: 3,251 select top 1 *
from (select *
from (select * from table where columname > '2') X
where columname > '4') Y
where columname > '6'
order by columname desc |
Forum: MS SQL Apr 23rd, 2008 |
| Replies: 2 Views: 7,635 update ABC
set XYZ = left(XYZ, 8) + 'A' + substring(XYZ, 9, 1000)
where XYZ like '%P' and XYZ not like '%A%' |
Forum: MS SQL Apr 22nd, 2008 |
| Replies: 2 Views: 2,862 I think you use Transaction. So you must start Distributed Transaction Coordinator on both server. |
Forum: MS SQL Apr 14th, 2008 |
| Replies: 1 Views: 776 I think you can create identity columns.
create table #tmpTemp
(ID int identity(1,1),
Code varchar(255),
Name varchar(255))
insert #tmpTemp (Code, Name)
select 'A', 'AA' -->... |
Forum: MS SQL Apr 10th, 2008 |
| Replies: 2 Views: 1,211 The correct code is:
select * from mail3 where email like '%+%' or email like '%*%' |
Forum: MS SQL Apr 2nd, 2008 |
| Replies: 2 Views: 2,810 Hope this code can help you.
1. Execute your first SP in query analyzer to show the columns list.
2. Create temporary table and the field must the same as first SP columns
create table... |
Forum: MS SQL Mar 20th, 2008 |
| Replies: 2 Views: 3,192 Try this code in Query Analyser. It enough for small data. If you want to use for big data, modify the code.
set nocount on
create table #tmpName (ID int, [Name] varchar(255))
create table... |
Forum: MS SQL Feb 14th, 2008 |
| Replies: 2 Views: 2,811 Try this code
select 1 as EmpID, 'John' as EmpName, '2007/01/01' as DateOfBirth
into #tmpData
union all
select 2 as EmpID, 'Anne' as EmpName, '2007/01/05' as DateOfBirth
union all
select 3... |
Forum: MS SQL Feb 6th, 2008 |
| Replies: 6 Views: 8,151 you need to create table tb_IPList (IP varchar(20)) and code (in ASP) below:
<%
option explicit
Dim Conn as object
Dim RS as object
set Conn = createobject("ADODB.Connection")
Conn.Mode = 3... |