sq;lset

insert into titles(title_id,title) values('fgjjjjjjjjjjj0','hhj0')
insert into titles(title_id,title) values('20','30')


select * from titles
drop proc addtitle
go
create proc addtitle(@title_id varchar(50),@title varchar(50))
as
begin
declare @sql varchar(50)
set @sql='insert into titles(title_id,title) values('''+@title_id+''','''+@title+''')'
print @sql
---exec(@sql)
end
go

exec addtitle 'w12','1w3'

select * from titles


---------------------------------------------------
drop proc seltitle
go
create proc seltitle(@type varchar(50))
as
begin
declare @sql varchar(50)
set @sql='select * from titles where type='''+@type+''''
exec(@sql)
end
go
--------------------
exec seltitle 'business'

drop proc deltitle
go
create proc deltitle(@id varchar(50))
as
begin
declare @sql varchar(50)
set @sql='delete from titles where title_id='''+@id+''''
exec(@sql)
end
go

---------------------------------
drop proc addtitle
go
create proc addtitle(@title_id varchar(50),@title varchar(50))
as
begin
declare @sql varchar(5000)

set @sql='insert into titles(title_id,title) values('''+@title_id+''','''+@title+''')'
---print @sql
exec(@sql)
end
go
exec addtitle 'sdf','w'
exec deltitle '12'

create proc asdl
as
begin
end
go

drop proc getid
go
create proc getid(@int int)
as
begin

declare @id varchar(50)
print Convert(varchar(50),getdate(),112)
end
go


exec getid 1
select * from titles


select datediff(yy,pubdate,getdate()) from titles
select dateadd(yy,5,pubdate) from titles
select len(substring(title,1,1)) from titles
select len(left(title,5)) from titles


create proc zong(@table varchar(50))
as
begin
declare @int int
declare @sql varchar(500)
set @sql='select count(*) from '+@table
--set @int = cast(exec(@sql) as int)
--print @int
end
go


create proc zongshu(@int int output)
as
begin

select @int=count(*) from titles
print @int
end
go

declare @int int
exec zongshu @int output
print @int
go

select count(*) from titles

select * from titles


select case len(title) when 2 then 200 else 300 end from titles

你可能感兴趣的:(sql,Go)