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
 General SQL Server Forums
 New to SQL Server Programming
 query to a view

Author  Topic 

ann06
Posting Yak Master

171 Posts

Posted - 2008-11-08 : 01:19:34
hi guys,

i have a query that includes a cursor to concatenate rows for similar id the query contains temp tables and varibles. i want to save this query as view because the software only picks reports created as a view.
its not permitting me to save the query as a view.
what should i do in this case?

thank you

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-08 : 03:52:23
are you trying to concatenate values as a comma seperated list?
Go to Top of Page

lionofdezert
Aged Yak Warrior

885 Posts

Posted - 2008-11-08 : 04:09:43
Temp tables can be used with in a session (other then global temp tables like @@tmpTable) and temp table cannot have a foreign key so it cannot be used in views, reports can be linked with store procedures.
Also read following :
http://www.sqlteam.com/article/temporary-tables
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-08 : 04:42:46
quote:
Originally posted by lionofdezert

Temp tables can be used with in a session (other then global temp tables like @@tmpTable) and temp table cannot have a foreign key so it cannot be used in views, reports can be linked with store procedures.
Also read following :
http://www.sqlteam.com/article/temporary-tables



global temp tables are like ##tmTable not @@tmpTable
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-08 : 04:50:19
for concatenating rows you dont need any temp tables. you can either use a udf to achieve this or use xml methods if you're using sql 2005
Go to Top of Page

ann06
Posting Yak Master

171 Posts

Posted - 2008-11-08 : 06:40:12
i will use udf instead of cursor, but i would like to know is all types of declares will not be permitted in views and what else ?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-08 : 07:08:09
you can call functions inside select statements of view.
Go to Top of Page
   

- Advertisement -