insert into tblNAME (id, name, description, size) values (201, 'a name','a description', 69)
UPDATE tblNAME
SET Name = 'another name' ,
description = 'another description'
WHERE ID = 201
DECLARE @rc int
SELECT {fields}
FROM tblMessages
INNER JOIN tblForums ON tblForums.ForumID = tblMessages.ForumID
WHERE tblForums.Visible = 1 AND
(tblMessages.Subject Like '%searchText%' OR tblMessages.Message Like '%searchText%') AND
CDate(tblMessages.DateOfPost) < '#" & Date() - 31 & "#'
ORDER BY tblMessages.DateOfPost DESC
SELECT @rc=@@rowcount
SELECT @rc
/* SET these server options before compiling any sproc */
SET ANSI_WARNINGS OFF
SET ANSI_NULLS ON
SET ANSI_PADDING OFF
SET QUOTED_IDENTIFIER OFF
SET ANSI_NULL_DFLT_ON OFF
SET IMPLICIT_TRANSACTIONS OFF
SET NOCOUNT ON
IF EXISTS (SELECT Name FROM sysobjects WHERE Name="simpleStoredProc" AND Type="P")
DROP PROCEDURE simpleStoredProc
GO
CREATE PROCEDURE simpleStoredProc
@New int,
@ID int,
@Name varchar(50),
AS
-- Do we want to create or update
IF (@New = 1)
BEGIN
Insert into tblName Values(@ID,@Name)
GOTO Cleanup
END
Update tblName
Set Name=@Name,
Where ID= @ID
Cleanup:
RETURN 0
GO
GRANT EXECUTE ON simpleStoredProc TO PUBLIC
GO
DECLARE @iPid int
DECLARE @iSid int
DECLARE @iLid int
DECLARE SNCursor Cursor STATIC FOR
OR
DECLARE SNCursor Cursor FOR -- this would be dynamic and you cant get cursor_rows
SELECT x,y,z
FROM tblXX
OPEN SNCursor
FETCH NEXT FROM SNCursor INTO @iPid,@iSid,@iLid
SELECT @cc=@@CURSOR_ROWS
WHILE @@fetch_status = 0
BEGIN
-- -------------------------
-- Place Calculations here
-- -------------------------
UPDATE tblXX
SET z=1
WHERE x=@iPid AND y = @iSId AND z = @iLId
-- -------------------------
-- End Calculations
-- -------------------------
FETCH NEXT FROM SNCursor INTO @iPid,@iSid,@iLid
END
CLOSE SNCursor
DEALLOCATE SNCursor
declare @vchString varchar(255)
declare @vchOwnerid varchar(255)
declare @iLength int
declare @iComma int
declare @iOwnerid int
select @vchString = "1,2,3,4,5,6,7,8,9,10"
while ltrim(rtrim(@vchString)) <> ""
begin
select @iLength = Len(@vchString)
select @iComma = CHARINDEX(",", @vchString)
if @iComma <> 0
begin
select @iOwnerId = Convert(int,Left(@vchString, @iComma - 1))
select @vchString = Right(@vchString, (@iLength - @iComma))
end
else
begin
select @iOwnerId = Convert(int,@vchString)
select @vchString = ""
end
select @iOwnerId
continue
end
BEGIN TRANSACTION
UPDATE tblNAME
SET Name = 'another name' ,
description = 'another description'
WHERE ID = 201
IF @@error = 0
BEGIN
COMMIT TRANSACTION
END
ELSE
BEGIN
SELECT @iReturnCode = 1
ROLLBACK TRANSACTION
END
SELECT I.iIncidentId ,
--ED.iSystemId ,
I.vchProductID ,
I.iStatusID ,
--RP.iParameterID ,
RP.vchParameterDesc as 'vchStatus' ,
I.iIncidentTypeId ,
--RP2.iParameterID ,
RP2.vchParameterDesc as 'vchIncidentType' ,
ED.chFieldName ,
vchDataValue = ( Case IsNumeric(ED.vchDataValue)
WHEN 1 THEN
( SELECT vchParameterDesc
FROM ReferenceParameters
WHERE iParameterID = ED.vchDataValue )
ELSE
ED.vchDataValue
END
)
FROM INCIDENT I
JOIN ReferenceParameters RP ON RP.iParameterId=I.iStatusID
JOIN ReferenceParameters RP2 ON RP2.iParameterId=I.iIncidentTypeId
JOIN ExpansionData ED ON ED.iSystemId=I.iIncidentId
WHERE I.iOwnerID=100018
AND I.iIncidentTypeId > 400123
AND I.iIncidentTypeId < 400128
AND I.iIncidentcategory = 3
AND I.tiRecordStatus = 1
outer join will return a record set even if the join condition isn't reached inner join only returns record set if join condition is reached.
Normalization is the process of organizing data in a database. This includes creating tables and establishing relationships between those tables according to rules designed both to protect the data and to make the database more flexible by eliminating two factors: redundancy and inconsistent dependency.