473,387 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How can sole that

I have a code when running it give this error messege (in sql server 2000)
Server: Msg 156, Level 15, State 1, Line 20
Incorrect syntax near the keyword 'EXEC'.

this is a part of the code
Expand|Select|Wrap|Line Numbers
  1. set nocount on
  2. create table #DISTINCTC(
  3.   [name] nvarchar(120)
  4. )
  5. insert into #DISTINCTC SELECT Column_Name FROM INFORMATION_SCHEMA.COLUMNS WHERE Table_Name = 'AGEN'
  6. ------------------------
  7. select * from #DISTINCTC
  8. declare Dist cursor for
  9.  select [name]from #DISTINCTC 
  10. open Dist
  11. DECLARE @z int
  12. declare @x nvarchar(120)
  13. declare @y nvarchar(120)
  14. fetch next from Dist into @x
  15.  while @@fetch_status=0
  16.  begin 
  17. set @y = @x;
  18.  set @z=EXEC('select count(distinct '+@y+') from AGEN')
  19. if (@z <= 10)
  20.  begin
  21.   set nocount on
  22.   create table #DISTINCTC1(
  23.     DistinctVal nvarchar(4000)
  24.   )
  25.   insert into #DISTINCTC1 EXEC('select distinct '+@y+' from AGEN')
  26.   ------------------------ 
  27.   declare Insertion cursor for
  28.   select * from #DISTINCTC1
  29.   open #DISTINCTC1
  30.   Declare @I nvarchar(4000)
  31.   FETCH NEXT FROM Insertion INTO @I
  32.   WHILE @@FETCH_STATUS = 0
  33.    begin
  34.    EXEC('insert into SATIS values("AGEN",'+@y+','+@I+')') 
  35.    FETCH NEXT FROM Insertion INTO @I
  36.    end
  37.  
  38.  end
  39. fetch next from Dist into @x 
  40.  end
  41. close Insertion
  42. Deallocate Insertion
  43. close Dist 
  44. Deallocate Dist 
  45. drop table #DISTINCTC
what shall I do
Jan 27 '09 #1
0 978

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: sentinel | last post by:
Hi, I'm currently writing a mulit-page form app that uses a session to retain data from each form element in order for the user to jump between pages, then the final data is passed to a calculation...
1
by: fartsniff | last post by:
hey all. for a small website, based off of phpnuke. running on a 2.4 down / 512 up cable connection, doing medium traffic. is it worth encoding the site using zend safeguard suite ? overall,...
2
by: ChronicFatigue | last post by:
Given that some browsers dont have javascript enabled.... do developers try to avoid using javascript when a php alternative can be used? What sort of alternative php scripts are often used?
1
by: Mark Hanford | last post by:
I'm after a regular expression that looks through a string for a certain code, and then replaces part of that code with some markup: So look in this string: this text contains (T123) a code. ...
1
by: Timothy Rue | last post by:
I found the online and free PHP manual(s) but what I need is one that is plain text/ascii Is there such a beast and if not what is the closest to it? I'd like to do my own markup on it. ...
383
by: John Bailo | last post by:
The war of the OSes was won a long time ago. Unix has always been, and will continue to be, the Server OS in the form of Linux. Microsoft struggled mightily to win that battle -- creating a...
0
by: O=O=O AriZOnA O=O=O | last post by:
Cazz. .... c'è il sole ..... ma porc putt me tocca pija la macchina ... perchè c'ho delle cose da portare ... ciuz! -- O=O=O AriZOnA O=O=O
3
by: KavvY | last post by:
How can I get a selected index changed event to fire, when the DropDownList only has one item? Thanks, Rich.
3
by: windandwaves | last post by:
Hi Folk I am running a site (A) that has a US mirror (B). This means that all the data from A is copied daily to B. On the site, I keep some statistics of the pages people visit, tracking...
3
by: Chris Forone | last post by:
its ok to return *this as reference (C++ FAQ L). but is it also in singleton pattern (ctor example below)? Timer* Timer::sole(0); // static Timer& Timer::Get() // static { return sole ?...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.