Tuesday, March 27, 2012

exec statement

hi guys

maybe an easy one for you

in stored procedure I create follving select

@.cmd = 'select ' + @.column_name + 'from ticket_dump_datawarehouse '
execute (@.cmd)

problem is thant I want to gave return value from this select

something like
set @.return = execute(@.cmd)

but I recieve error

Incorrect syntax near the keyword 'execute'

Can I do that some other way?return
which value?
Originally posted by mikosan
hi guys

maybe an easy one for you

in stored procedure I create follving select

@.cmd = 'select ' + @.column_name + 'from ticket_dump_datawarehouse '
execute (@.cmd)

problem is thant I want to gave return value from this select

something like
set @.return = execute(@.cmd)

but I recieve error

Incorrect syntax near the keyword 'execute'

Can I do that some other way?|||this is whole select.

sorry I forgot to finish it

@.cmd = 'select ' + @.column_name + 'from ticket_dump_datawarehouse where id = 10'

execute (@.cmd)

value from select statement = value in column @.column_name|||USE Northwind
GO

DECLARE @.sql varchar(8000), @.OrderId int

SELECT @.SQL = 'SELECT TOP 1 OrderId INTO myTable99 FROM Orders'

EXEC(@.SQL)

SELECT @.OrderId = OrderId FROM myTable99

SELECT @.OrderId
GO

DROP TABLE myTable99
GO

No comments:

Post a Comment