 |
SoftTree Technologies
Technical Support Forums
|
|
Author |
Message |
ssandu
Joined: 26 Feb 2007 Posts: 95 Country: Romania |
|
Code snippet for CTE |
|
Hi
I am trying to make a code snippet for SQL Server's CTE
Something like
SET NOCOUNT ON;
WITH somemane (columns)
AS
(
SELECT columns from sometable
)
is it possible ?
with
$PROMPT(proc_name,Cum se numeste CTE)$
SET NOCOUNT ON;
WITH $proc_name$ ( $COLUMNS$ )
AS
(
select $COLUMNS$ from $OBJECT$ where |
)
select * from $proc_name$
I can't get table name on $OBJECTS$
it's only dbo
Thank's
|
|
Mon Nov 19, 2012 6:39 am |
|
 |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
|
|
I needed something similar ages ago and created a snippet for it. It has gone through several modifications since then. You hardly ever need to select all the columns or without any filtering, hence to obtain some flexibility here, it rather works on select queries than on individual tables. But the same effect can be achieved if you apply it to an 'select column1, column2 as whatever, ... from table where blablabla'. And you're free to alter it in any way you want, of course, therefore you can reduce it to pick a table from the popup. It also includes option for creating a table variable or temporary table. Check it here.
EDIT: it might need some modifications to work with SA earlier than 6.3.135 Pro.
|
|
Mon Nov 19, 2012 7:43 am |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|