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 2005 Forums
 Transact-SQL (2005)
 Dynamic Crosstab in SQLExpress

Author  Topic 

sg2255551
Constraint Violating Yak Guru

274 Posts

Posted - 2007-07-30 : 11:24:52
hi

I found this link http://www.sqlteam.com/article/dynamic-cross-tabs-pivot-tables

I am using SQLExpress and when i try to save the stored procedure it did not allow me to.

I used it on SQL Server 2005 and is working fine.

Any ideal how can i use this dynamic Cross Tab in SQL Express? Thanks a million.

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-07-30 : 11:40:27
what error do you get?


_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

sg2255551
Constraint Violating Yak Guru

274 Posts

Posted - 2007-07-30 : 11:54:53
Incorrect syntax near the keyword 'Pivot'
Go to Top of Page

sg2255551
Constraint Violating Yak Guru

274 Posts

Posted - 2007-07-30 : 12:04:43
Also, When i use SQL 2005 using Northwind, is all fine. but the moment i change the query to AdventureWorks, it gave me: Incorrect syntax near the keyword 'Pivot'. It is very strange.
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-07-30 : 12:06:01
Pivot is a reserved word in SQL 2005; try replacing the name used in the article with something else, such as "Pivot2".

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

sg2255551
Constraint Violating Yak Guru

274 Posts

Posted - 2007-07-30 : 12:09:23
Ok, it is done. Thanks a million
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-07-30 : 12:20:56
quote:
Originally posted by sg2255551

Also, When i use SQL 2005 using Northwind, is all fine. but the moment i change the query to AdventureWorks, it gave me: Incorrect syntax near the keyword 'Pivot'. It is very strange.
What is your compatibility level set to?



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

sg2255551
Constraint Violating Yak Guru

274 Posts

Posted - 2007-07-30 : 20:02:38
Yes, now i know the problem. NW was set to 80. Thanks Peso
Go to Top of Page

sg2255551
Constraint Violating Yak Guru

274 Posts

Posted - 2007-07-30 : 21:11:57
How do I concat two fields together? This is the part: 'Max(DateName(day,StartDate)+'' ''+ Datename(day,EndDate))'

execute dbo.crossTab 'SELECT EventTitle,EventGroup FROM dbo.tblEvent INNER JOIN dbo.tblDate ON (tblEvent.EventID = tblDate.EventID)
group by EventTitle, EventGroup , 'Max(DateName(day,StartDate)+'' ''+ Datename(day,EndDate))','DATENAME(month, dbo.tblDate.StartDate)','tblDate'
Go to Top of Page

sg2255551
Constraint Violating Yak Guru

274 Posts

Posted - 2007-07-30 : 21:29:04
Ok, I have manage to solve it. Thanks
Go to Top of Page

sg2255551
Constraint Violating Yak Guru

274 Posts

Posted - 2007-07-30 : 22:01:34
how do I do an order by of month in the cross tab

For example: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec. Thanks

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-07-31 : 02:11:52
You mean the order of COLUMNS?
Hardcode the PIVOT columns in the query.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

sg2255551
Constraint Violating Yak Guru

274 Posts

Posted - 2007-07-31 : 05:11:32
ok
Go to Top of Page
   

- Advertisement -