Search Results

Showing results 1 to 40 of 40
Search took 0.01 seconds.
Search: Posts Made By: huangzhi
Forum: MS SQL 4 Days Ago
Replies: 6
Views: 325
Posted By huangzhi
I think there are some (ClientID = 1126) in table Receipts.
Change your SQL to:


SELECT Clients.ClientID, Clients.WholeName,
SUM(CASE WHEN Payments.Creditorid = 0 THEN Payments.Amount ELSE...
Forum: MS SQL 5 Days Ago
Replies: 6
Views: 325
Posted By huangzhi
I think there are data double in table Receipts.
Please give some data for example.
Forum: MS SQL 5 Days Ago
Replies: 2
SQL
Views: 275
Posted By huangzhi
or use these commands:

declare @Day varchar(255), @Sales int, @strSales varchar(1024)

CREATE TABLE #tmpSales ([Day] varchar(255), SalesQuantity int)
INSERT #tmpSales
SELECT 'Monday', 20...
Forum: MS SQL 5 Days Ago
Replies: 2
SQL
Views: 275
Posted By huangzhi
I think you cannot use simple sql command to get result like that. You can use cursor to concatenate the sales quantity like below:

declare @Day varchar(255), @Sales int

create table #tmpSales...
Forum: MS SQL 10 Days Ago
Replies: 4
Views: 375
Posted By huangzhi
Try code below


set nocount on
CREATE TABLE #tmpName (ID int, [Name] varchar(255))
CREATE TABLE #tmpRelation (ID int, ID_Parent int)

INSERT #tmpName (ID, [Name]) select 1, 'value1'
INSERT...
Forum: MS SQL 12 Days Ago
Replies: 4
Views: 375
Posted By huangzhi
Can u give some data and the result you want?
or you can see http://www.daniweb.com/forums/thread114466.html.
Forum: MS SQL 15 Days Ago
Replies: 4
Views: 368
Posted By huangzhi
I do not understand why if test2.id = 2 then the result will 1 NULL NULL NULL. if you want that result try below:

SELECT #test1.ID, case when #test1.id <> isNull(#test2.id,0) then null else name1...
Forum: MS SQL 15 Days Ago
Replies: 4
Views: 368
Posted By huangzhi
create table #test1 (ID int, name1 varchar(255))
insert #test1 values (1, 'value1')


create table #test2 (ID int, name2 varchar(255))
insert #test2 values (1, 'value2')

create table #test3...
Forum: MS SQL Aug 25th, 2009
Replies: 9
Views: 8,057
Posted By huangzhi
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: 649
Posted By huangzhi
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,947
Posted By huangzhi
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,085
Posted By huangzhi
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: 739
Posted By huangzhi
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: 350
Posted By huangzhi
You can use table master.dbo.sysprocesses.
This system table contain connected users.
Forum: MS SQL Nov 24th, 2008
Replies: 3
Views: 870
Posted By huangzhi
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: 624
Posted By huangzhi
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,442
Posted By huangzhi
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,442
Posted By huangzhi
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,035
Posted By huangzhi
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: 695
Posted By huangzhi
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: 648
Posted By huangzhi
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,402
Posted By huangzhi
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,663
Posted By huangzhi
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,501
Posted By huangzhi
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: 897
Posted By huangzhi
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,654
Posted By huangzhi
select * from tb_TableName where AColumn like 'user1%'
Forum: MS SQL Jun 9th, 2008
Replies: 1
Views: 2,725
Posted By huangzhi
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,244
Posted By huangzhi
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,289
Posted By huangzhi
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,427
Posted By huangzhi
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,761
Posted By huangzhi
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,356
Posted By huangzhi
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,862
Posted By huangzhi
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,916
Posted By huangzhi
I think you use Transaction. So you must start Distributed Transaction Coordinator on both server.
Forum: MS SQL Apr 14th, 2008
Replies: 1
Views: 780
Posted By huangzhi
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,223
Posted By huangzhi
The correct code is:

select * from mail3 where email like '%+%' or email like '%*%'
Forum: MS SQL Apr 2nd, 2008
Replies: 2
Views: 2,826
Posted By huangzhi
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,269
Posted By huangzhi
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,878
Posted By huangzhi
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,216
Posted By huangzhi
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...
Showing results 1 to 40 of 40

 


About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC