Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Having Problems creating a Table-please help

Author  Topic 

adiboy0420
Starting Member

10 Posts

Posted - 2012-07-16 : 21:02:51
hello everyone,

i am new at creating table

and here is my code



create function fn_retlatthree
(@stg varchar (1000)

returns @point table
( one varchar(1000),
two varchar (1000),
Three varhcar (1000))

as

begin--1

declare @x varchar(1000)
declare @y varchar(1000)
declare @z varchar(400)
set @x= @stg

while (CHARINDEX(',',@x)>0)
begin--2

set @z=@y
set @y=LEFT(@x,charindex(',',@x)-1)
set @x=right(@x,len(@x)-len(@y)-1)

end--2

select @z
select @y
select @x


insert into @point values (@z,@y,@x)

Return ()

end--1



-----------

its giving me error

Msg 102, Level 15, State 1, Procedure fn_retlatthree, Line 5
Incorrect syntax near 'returns'.
Msg 137, Level 15, State 2, Procedure fn_retlatthree, Line 17
Must declare the scalar variable "@stg".
Msg 1087, Level 15, State 2, Procedure fn_retlatthree, Line 33
Must declare the table variable "@point".


can anyone please help me fix this syntex ?!?!? Please. !!!!

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-07-16 : 21:59:07
you dont need () at the end
you also have ) missing after parameter definition
another issue is typo on varchar for three column

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

adiboy0420
Starting Member

10 Posts

Posted - 2012-07-16 : 22:08:57
got it Thank you worked perfect,

but i also had to take out

select @z
select @y
select @x

at the end of the code,
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-07-16 : 22:18:10
quote:
Originally posted by adiboy0420

got it Thank you worked perfect,

but i also had to take out

select @z
select @y
select @x

at the end of the code,


it wont cause any error but would simply echo results out

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -