Showing posts with label sql server tutorials. Show all posts
Showing posts with label sql server tutorials. Show all posts

Monday, November 19, 2012

SQL Queries for Beginners

--Creating Table in SqlServer 2008

CREATE TABLE EMPLOYEE
  (
  Empid int,
  EmpName varchar(50),
  Salary  Varchar(50)
  )

--Creating Stored procedure

CREATE PROCEDURE SP_INSERTEMP
(
  @EmpName varchar(50),
  @Sal Varchar(50)
)
AS
BEGIN
--statement that you want retrieve or modify here inserting new employee in Employee table
INSERT INTO EMPLOYEE (EMPNAME,SALARY) VALUES(@EmpName,@sal)
END


--Creating Functions in sql server returning table

CREATE  FUNCTION FN_RETURNTABLE
(@tblName varchar(50)) Returns
@tblRecords table(tblNames varchar(25)
as
begin
declare @names varchar(50)

Insert into tblRecords values(@names)

return
end