Posts
 
Reputation
Joined
Last Seen
0 Reputation Points
100% Quality Score
Upvotes Received
1
Posts with Upvotes
1
Upvoting Members
1
Downvotes Received
0
Posts with Downvotes
0
Downvoting Members
0
0 Endorsements
Ranked #914
~8K People Reached
Favorite Forums
Favorite Tags

41 Posted Topics

Member Avatar for pc131

[code] 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 (ID int, name3 varchar(255)) insert #test3 values (3, 'value3_01') insert #test3 values (4, 'value3_02') select #test1.ID, name1, name2, name3 from #test1 inner …

Member Avatar for pssingh1001
0
368
Member Avatar for walkermat

Try this code below: [code] 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 [/code]

Member Avatar for dwyaris
0
270
Member Avatar for konczuras

change your command into: [code] select * from (Select table_name from information_schema.tables where table_name= @table_name ) AliasName [/code] change your second command into: [code] declare @table_name varchar(255) select @table_name = 'sysdatabases' exec ('select * from ' + @table_name) [/code]

Member Avatar for vectorsoftware
0
187
Member Avatar for sangfroid

[Code] 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' union all select 'ProductA', 12.01, '01/02/2008' union all select 'ProductB', 15.12, '12/01/2005' union all select 'ProductB', 16.00, '01/09/2008' union all select 'ProductB', 16.24, '01/15/2008' declare …

Member Avatar for harie.in
0
138
Member Avatar for everhett.raman

1. All lines are execute. Not just 1 line below the. If you want to exit, use severity more than 10 (> 10). 2. No comment 3. I am not use TRY CATCH. I usually use RAISERROR alone with severity 16. So the error will be send to my application …

Member Avatar for fx1250s
0
216
Member Avatar for faintfascinatio

May be this query can solve your problem: [CODE] DECLARE @person xml, @idoc int, @Local varchar(255), @XML varchar(255) set @person = ' <ROOT> <people> <person.1> <fname>brian</fname> <lname>smith</lname> </person.1> <person.11> <fname>joe</fname> <lname>carey</lname> </person.11> </people> </ROOT>' EXEC sp_xml_preparedocument @idoc OUTPUT, @person select @idoc declare cs_Parent cursor forward_only for select LocalName FROM OPENXML(@idoc, …

Member Avatar for faintfascinatio
0
150
Member Avatar for Gdyson

Use DISTINCT to eliminate double row in Pf.RecruiterID, Pf.ProjectID. Then count the ProjectID The query may be looks like below: [CODE] declare @StartDate smalldatetime, @EndDate smalldatetime select @StartDate = '2010/01/01', @EndDate = '2010/12/31' select RecruiterID, count(*) from (select distinct Pf.RecruiterID, Pf.ProjectID from tblProfiles Pf inner join tblProjects Pr on Pf.ProjectID …

Member Avatar for Gdyson
0
104
Member Avatar for thahir
Member Avatar for huangzhi
0
203
Member Avatar for neo.mn
Member Avatar for huangzhi
0
137
Member Avatar for dh111

Please give some data for an example. Or you can read help about : 1. SET IDENTITY_INSERT for inserting ID to another table. 2. IDENT_CURRENT('table_name') to return last ID. 3. DBCC CHECKIDENT to return last ID and corrects the identity value

Member Avatar for huangzhi
0
112
Member Avatar for _taz_

I think there are data double in table Receipts. Please give some data for example.

Member Avatar for _taz_
0
172
Member Avatar for Tank50
Re: SQL

I think you cannot use simple sql command to get result like that. You can use cursor to concatenate the sales quantity like below: [CODE=ms sql] declare @Day varchar(255), @Sales int create table #tmpSales ([Day] varchar(255), SalesQuantity int) insert #tmpSales select 'Monday', 20 union all select 'Monday', 302 union all …

Member Avatar for huangzhi
0
122
Member Avatar for elauri

Can u give some data and the result you want? or you can see [url]http://www.daniweb.com/forums/thread114466.html[/url].

Member Avatar for huangzhi
0
123
Member Avatar for deostroll

May be this SQL can solve this problem: [code] 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 'E' union all select 'F' union all select 'G' union all select 'H' union all select 'I' …

Member Avatar for huangzhi
0
183
Member Avatar for HBMSGuy

maybe you can use CASE ... WHEN ... END command like below: [code] select cast(case when exists (SELECT * FROM UserList WHERE UserName = 'Tester') then 1 else 0 end as bit) [/code]

Member Avatar for HBMSGuy
0
172
Member Avatar for culebrin

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 [code] create table #tmpTemp ( Field1 varchar(255), Field2 varchar(255)) [/code] 3. Insert the columns from first SP …

Member Avatar for culebrin
0
179
Member Avatar for dfs3000my

Make it subquery like below: [Code] select [Year], [Month], sum([Benefits Rating]) as [Benefits Rating], sum([Facilities Rating]) as [Facilities Rating] from (...... your origin query ......) X group by [Year], [Month] [/Code]

Member Avatar for dfs3000my
0
147
Member Avatar for nokomoli

Try this query below: [Code] 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 T1.ID = T2.ID) UNION ALL (SELECT SUM(T3.Amount+T4.Amount) AS Total FROM TABLE3 T3 INNER TABLE4 T4 ON T3.ID = T4.ID) ) DERIVETBL) …

Member Avatar for huangzhi
0
693
Member Avatar for ffgordy

You cannot use just select command. You must use cursor to list the time list. Try and modify code below: [Code] set nocount on declare @CounterDate smalldatetime, @MaxDate smalldatetime create table #tmpAct ( ActDate smalldatetime, Act varchar(255) ) create table #tmpChart ( StartTime smalldatetime ) insert #tmpAct (ActDate, Act) select …

Member Avatar for huangzhi
0
107
Member Avatar for mcarloskewl

You can use table master.dbo.sysprocesses. This system table contain connected users.

Member Avatar for huangzhi
0
80
Member Avatar for rebeka.six

Try this command: [code] select T1.idx, T2.idy, T2.u from Table1 T1 right join Table2 T2 on T1.idy = T2.Idy and T1.idx = 'one' [/code]

Member Avatar for rebeka.six
0
136
Member Avatar for nokomoli

[code] 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 [/code]

Member Avatar for nokomoli
0
173
Member Avatar for lekfir

Try this code below: [code] 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 Col4, 0 as Col5, 0 as Col6, …

Member Avatar for huangzhi
0
147
Member Avatar for Jahira

Try this code below: [code] select top 1 * from (select top 6 * from #tmpSalary order by Salary) X order by Salary desc [/code]

Member Avatar for huangzhi
0
102
Member Avatar for bugmenot

Try code below: [code] declare @Ask varchar(255) select @Ask = '100.100.2225.104' create table #tmpAddr ( Addr varchar(255), Inc int) insert #tmpAddr select '100.100.2225.100', 5 insert #tmpAddr select '100.100.2225.103', 5 insert #tmpAddr select '100.100.2225.110', 5 select left(Addr, len(Addr) - charindex('.', reverse(Addr))), right(Addr, charindex('.', reverse(Addr)) - 1) from #tmpAddr where @Ask between …

Member Avatar for huangzhi
0
104
Member Avatar for yorks

Change your Select check to: charindex(' ' + uzip + ' ',' ' + 'S10 S11 S7 S17 S8 S3 S30' + ' ') > 0 This code will check 'S1' <> 'S10'

Member Avatar for huangzhi
0
208
Member Avatar for jtok

Try this one: [code] select completed from table order by case when completed is null then 0 else 1 end, completed desc [/code]

Member Avatar for jtok
0
215
Member Avatar for peanutong
Member Avatar for prasannapower
0
113
Member Avatar for newMeg

You can combine your 2 query with 'UNION ALL' or 'UNION' like below: [code] SELECT * FROM TBL_Modules WHERE identifier IN ('1','2','3','4','5','6') ORDER BY Identifier union all SELECT m.* FROM TBL_Modules m,TBL_ComponentList c WHERE m.Identifier=c.CompIdentifierID AND c.CreatedBy = '2418' ORDER BY m.Identifier [/code]

Member Avatar for huangzhi
0
122
Member Avatar for mhaskell

[Code] 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' union all select 'ProductA', 12.01, '01/02/2008' union all select 'ProductB', 15.12, '12/01/2005' union all select 'ProductB', 16.00, '01/09/2008' union all select 'ProductB', 16.24, '01/15/2008' select …

Member Avatar for huangzhi
0
103
Member Avatar for dtmd

Try this code. [code] SELECT DISTINCT COALESCE (s3.ADM_CODE, s1.ADM_CODE) AS Expr1, COALESCE (s3.FULLNAME, COALESCE (COALESCE (CASE s2.shortform WHEN '' THEN NULL ELSE s2.shortform END, s2.FULLNAMEND), COALESCE (CASE s1.shortform WHEN '' THEN NULL ELSE s1.shortform END, s1.FULLNAMEND))) AS name FROM worldcities_pro_states AS s1 LEFT OUTER JOIN worldcities_pro_states AS s2 ON s2.CC1 …

Member Avatar for huangzhi
0
161
Member Avatar for recursiveNugget

Try this code [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 tContacts c on u.contact_id = c.id left join (select user_id, count(*) as Doc_A from tDocumentsA group by user_id) Doc_A on c.id = Doc_A.user_id …

Member Avatar for recursiveNugget
0
892
Member Avatar for punitdam

You cannot increase this limit. You must change your program. See [url]http://www.daniweb.com/forums/thread114466.html[/url]. Hope this link can give you some idea.

Member Avatar for punitdam
0
400
Member Avatar for HugoCore

[code] select top 1 * from (select * from (select * from table where columname > '2') X where columname > '4') Y where columname > '6' order by columname desc [/code]

Member Avatar for huangzhi
0
48
Member Avatar for Wakhal

[code] update ABC set XYZ = left(XYZ, 8) + 'A' + substring(XYZ, 9, 1000) where XYZ like '%P' and XYZ not like '%A%' [/code]

Member Avatar for Wakhal
0
116
Member Avatar for kbrown123

I think you use Transaction. So you must start Distributed Transaction Coordinator on both server.

Member Avatar for kbrown123
0
83
Member Avatar for Jon182

I think you can create identity columns. [CODE] create table #tmpTemp (ID int identity(1,1), Code varchar(255), Name varchar(255)) insert #tmpTemp (Code, Name) select 'A', 'AA' --> replace with your view union all select 'B', 'BB' select * from #tmpTemp drop table #tmpTemp [/CODE]

Member Avatar for huangzhi
0
69
Member Avatar for mansi sharma

The correct code is: [icode]select * from mail3 where email like '%+%' or email like '%*%'[/icode]

Member Avatar for mansi sharma
0
109
Member Avatar for snow00

Try this code in Query Analyser. It enough for small data. If you want to use for big data, modify the code. [code=MSSQL] 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, 'Frank' insert #tmpName (ID, …

Member Avatar for snow00
0
576
Member Avatar for winsrividhya

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 as EmpID, 'Tony' as EmpName, '2007/01/08' as DateOfBirth union all select 4 as EmpID, 'Erin' as EmpName, '2007/02/28' as …

Member Avatar for SheSaidImaPregy
0
147
Member Avatar for kitkatsavvy

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 Conn.open "DRIVER={SQL Server};Server=YourServer;Database=YourDB" set RS = Conn.execute ("select 1 from tb_IPList where IP = '" + Request.ServerVariables("REMOTE_ADDR")) + "'" …

Member Avatar for huangzhi
0
247

The End.