Viewing 15 posts - 16 through 30 (of 37 total)
You can use this query too...
SELECT
COUNT (DISTINCT ACCOUNT)
FROM dxhistory
WHERE RANK=1
GROUP BY ACCOUNT, RANK
HAVING COUNT(RANK)>1
July 29, 2008 at 1:44 pm
UPDATE TABLE1
SET TABLE1.FIELD1 = TABLE1.FIELD1 + TABLE2.FIELD2A
FROM TABLE1
INNER JOIN TABLE2
ON TABLE1.FIELD2 = TABLE2.FIELD2b
May 22, 2008 at 9:39 am
Try this
insert into empcheck1
select * from emp
where emp.empid not in(select empid from empcheck1)
May 20, 2008 at 2:06 am
declare @i as numeric(18,0)
declare @sql as varchar(8000)
set @i =4
set @sql ='select top ' + convert(varchar,@i) + ' * from dbo.tbl_ls_feed_data'
exec(@sql)
May 16, 2008 at 2:23 am
SELECT 'Total'
,(SELECT SUM(totalprocessed)
FROM vw_total_numbers_0
WHERE RIGHT(trust,4) = 'goal') AS 'Total Goal'
,(SELECT SUM(totalprocessed)
FROM vw_total_numbers_0
WHERE RIGHT(trust,4) <> 'goal') AS 'Actual'
May 13, 2008 at 4:22 am
Execute dynamic SQL statement using sp_executesql system stored procedure, if you want a output to a variable. It allows input parameters as well as output parameters.
DECLARE @cmd NVARCHAR(100)
DECLARE @parm NVARCHAR(100)
DECLARE...
May 10, 2008 at 8:55 am
May 9, 2008 at 3:59 pm
Functionally, TOP and SET ROWCOUNT do the same thing. However, SET ROWCOUNT will affect any subsequent queries in a connection. To remove the row count option, use SET ROWCOUNT 0....
May 9, 2008 at 3:43 pm
Try this,
DBCC CHECKIDENT('MyCustomers', RESEED, 200)
May 9, 2008 at 7:09 am
You may do this way,
[font="Courier New"]DECLARE @cmd varchar(100)
DECLARE @fldname varchar(50)
DECLARE @number int
SET @fldname = 'ContactName'
CREATE TABLE #number (RecordCount INT)
SELECT @cmd = 'INSERT INTO #number SELECT COUNT(*) FROM CONTACT2 WHERE '...
May 8, 2008 at 4:04 pm
SQL compiler doesn't return any error message, if the table doesn't exist. Check this,
[font="Courier New"]if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[SomeThing]')
and OBJECTPROPERTY(id, N'IsUserTable') = 1)
select test...
May 8, 2008 at 1:16 pm
Try this,
[font="Courier New"]DECLARE @ID AS CHAR(2)
DECLARE @Name VARCHAR(10)
DECLARE @Region VARCHAR(10)
SET @ID = 'OH'
SET @Name = 'OHIO'
SET @Region = 'MIDWEST'
IF EXISTS(SELECT * FROM States WHERE [ID]=@ID)
BEGIN
INSERT INTO error_log VALUES(@ID + '...
May 8, 2008 at 10:04 am
You can't execute a store procedure inside the function!
May 8, 2008 at 3:25 am
Save the time in DATETIME data type in you database. When you retrieve you may convert it to the format you mentioned.
[font="Courier New"]DECLARE @date DATETIME
DECLARE @time CHAR(5)
SET @time = '07:45'
SET...
May 8, 2008 at 12:03 am
p21_view_invoice_hdr.invoice_date < DATEADD(dd,-90,GETDATE())
May 7, 2008 at 1:01 pm
Viewing 15 posts - 16 through 30 (of 37 total)