Showing posts with label procedures. Show all posts
Showing posts with label procedures. Show all posts

Friday, March 30, 2012

Problems with T-SQL Debugger and Query Analyzer

I'm receiving this error message on the majority of machines, from my
developers, trying to debug T-SQL Stored Procedures (including my machine)...
Server: Msg 504, Level 16, State 1, Procedure sp_sdidebug, Line 1
[Microsoft][ODBC SQL Server Driver][SQL Server]Unable to connect to debugger
on DESEN (Error = 0x800706ba). Ensure that client-side components, such as
SQLDBREG.EXE, are installed and registered on CONSOFT-08. Debugging disabled
for connection 89.
Strangely, one of the machines works fine, it's running Windows 2000...
The other machines runs Win2k or XP... None of them work...
The server and the client runs the same SQL version (SP3)...
I saw an article in BOL that didn't help to solve the problem (Troubleshoot
T-SQL Debugger)...
Does anybody knows something about that?
If you need any more information that could help you to determine the
problem, plz contact me... I'm very thank!!
Hi Rafa,
Is this article helpful then?
INF: Transact-SQL Debugger Limitations and Troubleshooting Tips for SQL
Server 2000
http://support.microsoft.com/default...b;en-us;280101
Yih-Yoon Lee
Rafa? wrote:
> I'm receiving this error message on the majority of machines, from my
> developers, trying to debug T-SQL Stored Procedures (including my machine)...
> Server: Msg 504, Level 16, State 1, Procedure sp_sdidebug, Line 1
> [Microsoft][ODBC SQL Server Driver][SQL Server]Unable to connect to debugger
> on DESEN (Error = 0x800706ba). Ensure that client-side components, such as
> SQLDBREG.EXE, are installed and registered on CONSOFT-08. Debugging disabled
> for connection 89.
> Strangely, one of the machines works fine, it's running Windows 2000...
> The other machines runs Win2k or XP... None of them work...
> The server and the client runs the same SQL version (SP3)...
> I saw an article in BOL that didn't help to solve the problem (Troubleshoot
> T-SQL Debugger)...
> Does anybody knows something about that?
> If you need any more information that could help you to determine the
> problem, plz contact me... I'm very thank!!

Problems with System Stored Procedures Permissions

Hello,
I have a problem with Server Traces. Actually I'm running some different
audit traces on SQL2K, that I can access with SQL Profiler or using System
UDF like "fn_trace_getinfo" and "fn_trace_gettable".
The problem is that I need to access to the audit trace files with a
different user, who is not in sysadmin role. So, I want this is user to be
capable to execute that system UDF.
I grant select permissions on "fn_trace_getinfo" to the user,but when I try
to execute a simple query like
"select * from :: fn_trace_getinfo (default)", I receive a message like
this:
Server: Msg 262, Level 14, State 12, Procedure fn_trace_getinfo, Line 10
FN_TRACE_GETINFO permission denied in database 'master'.
Despite this message I have the permissions I need on master. I've been
reading out in the web and books, and all them say that a member of fix
sysadmin role can execute the UDF. But I wonder if there is a way to give
permissions to another users.
Can anyone help me please?
Thanks in advance.
Victor wrote:
> Hello,
> I have a problem with Server Traces. Actually I'm running some
> different audit traces on SQL2K, that I can access with SQL Profiler
> or using System UDF like "fn_trace_getinfo" and "fn_trace_gettable".
> The problem is that I need to access to the audit trace files with a
> different user, who is not in sysadmin role. So, I want this is user
> to be capable to execute that system UDF.
> I grant select permissions on "fn_trace_getinfo" to the user,but when
> I try to execute a simple query like
> "select * from :: fn_trace_getinfo (default)", I receive a message
> like this:
> Server: Msg 262, Level 14, State 12, Procedure fn_trace_getinfo, Line
> 10 FN_TRACE_GETINFO permission denied in database 'master'.
> Despite this message I have the permissions I need on master. I've
> been reading out in the web and books, and all them say that a member
> of fix sysadmin role can execute the UDF. But I wonder if there is a
> way to give permissions to another users.
> Can anyone help me please?
> Thanks in advance.
Running traces in SQL 2000 is limited to system administrators. SQL 2005
allows you to grant trace rights using the Alter Trace grant.
David Gugick - SQL Server MVP
Quest Software
sql

Wednesday, March 28, 2012

Problems with Stored procedures

I am trying to recreate my database from work to my home machines. But use
Sql 2000.
One error I get is that bigint is invalid type - but my tables have bigints
in then
Another is that Scope_Identity is not valid - but it works fine at work.
Here is one Stored procedure (with errors at end).
****************************************
**************
CREATE PROCEDURE AddNewApplicantScreen
(
@.ClientID varChar(20),@.JobID bigInt,@.ApplicantID bigInt,@.PositionID
Int,@.Version Int, @.QuestionUnique Int, @.Answer Int,@.AnswerTime Int
)
AS
if not exists (Select ApplicantID from ftsolutions.dbo.ApplicantScreen
where ClientID = @.ClientID and JobID = @.JobID and ApplicantID =
@.ApplicantID and PositionID = @.PositionID and Version = @.Version
and QuestionUnique = @.QuestionUnique)
insert into
ApplicantScreen(ClientID,JobID,Applicant
ID,PositionID,Version,QuestionUnique
,Answer,AnswerTime)
values(@.ClientID,@.JobID,@.ApplicantID,@.Po
sitionID,@.Version,@.QuestionUnique,@.A
nswer,@.AnswerTime)
else
Update ftsolutions.dbo.ApplicantScreen set Answer=@.Answer,
AnswerTime=@.AnswerTime
where ClientID = @.ClientID and JobID = @.JobID and ApplicantID =
@.ApplicantID and PositionID = @.PositionID and Version = @.Version
and QuestionUnique = @.QuestionUnique
GO
Server: Msg 2715, Level 16, State 3, Procedure AddNewApplicantScreen, Line 0
Column or parameter #2: Cannot find data type bigint.
Server: Msg 2715, Level 16, State 1, Procedure AddNewApplicantScreen, Line 0
Column or parameter #3: Cannot find data type bigint.
Parameter '@.JobID' has an invalid data type.
Parameter '@.ApplicantID' has an invalid data type.
****************************************
************************************
***
Here is another:
****************************************
************************************
***
CREATE PROCEDURE spAddNewResume
(
@.ClientID varChar(20),@.PositionID Int,@.FirstName varChar(30),@.LastName
varChar(30),@.Email varChar(45),@.TicklerPhrase varChar(45),@.ResumeText
text,@.CoverSheet text
)
AS
declare @.ApplicantID int, @.JobID bigInt
if not exists (Select ApplicantID from ftsolutions.dbo.Applicant where
ClientID = @.ClientID and
LastName = @.LastName and FirstName = @.FirstName and Email = @.Email)
begin
begin tran
INSERT INTO Applicant
(ClientID,ApplicantID,PositionID,FirstNa
me,LastName,Email,DatePosted)
Select @.ClientID,COALESCE(max(ApplicantID),1000
)+1,@.PositionID,@.FirstName,
@.LastName,@.Email,getdate()
from ftsolutions.dbo.Applicant
where ClientID = @.ClientID
Select @.JobID = Scope_Identity()
Select @.ApplicantID=ApplicantID from ftsolutions.dbo.Applicant where JobID
= @.JobID
commit tran
end
else
begin
Select @.ApplicantID = ApplicantID from Applicant where ClientID = @.ClientID
and
LastName = @.LastName and FirstName = @.FirstName and Email = @.Email
INSERT INTO Applicant
(ClientID,ApplicantID,PositionID,FirstNa
me,LastName,Email,DatePosted) values
(@.ClientID,@.ApplicantID,@.PositionID,@.Fir
stName,
@.LastName,@.Email,getdate() )
Select @.JobID = Scope_Identity()
end
INSERT INTO ApplicantResume
(ClientID,ApplicantID,PositionID,FirstNa
me,LastName,Email,TicklerPhrase,Resu
meText,CoverSheet,JobID) values
(
@.ClientID,@.ApplicantID,@.PositionID,@.Firs
tName,@.LastName,@.Email,@.TicklerPhras
e,@.ResumeText,@.CoverSheet,@.JobID)
INSERT INTO JobApplicant (ClientID,ApplicantID,PositionID,JobID,R
esume)
Values(@.ClientID,@.ApplicantID,@.PositionI
D,@.JobID,getdate() )
select @.ApplicantID as ApplicantID,@.JobID as JobID
GO
Server: Msg 195, Level 15, State 10, Procedure spAddNewResume, Line 17
'Scope_Identity' is not a recognized function name.
Server: Msg 195, Level 15, State 1, Procedure spAddNewResume, Line 29
'Scope_Identity' is not a recognized function name.
****************************************
************************************
**
Why would that happen?
Thanks,
TomWhat does the following return on your home machine?
SELECT @.@.VERSION
Hope this helps.
Dan Guzman
SQL Server MVP
"tshad" <tfs@.dslextreme.com> wrote in message
news:OawFG9uGFHA.3156@.TK2MSFTNGP10.phx.gbl...
>I am trying to recreate my database from work to my home machines. But use
> Sql 2000.
> One error I get is that bigint is invalid type - but my tables have
> bigints
> in then
> Another is that Scope_Identity is not valid - but it works fine at work.
> Here is one Stored procedure (with errors at end).
> ****************************************
**************
> CREATE PROCEDURE AddNewApplicantScreen
> (
> @.ClientID varChar(20),@.JobID bigInt,@.ApplicantID bigInt,@.PositionID
> Int,@.Version Int, @.QuestionUnique Int, @.Answer Int,@.AnswerTime Int
> )
> AS
> if not exists (Select ApplicantID from ftsolutions.dbo.ApplicantScreen
> where ClientID = @.ClientID and JobID = @.JobID and ApplicantID =
> @.ApplicantID and PositionID = @.PositionID and Version = @.Version
> and QuestionUnique = @.QuestionUnique)
> insert into
> ApplicantScreen(ClientID,JobID,Applicant
ID,PositionID,Version,QuestionUniq
ue
> ,Answer,AnswerTime)
> values(@.ClientID,@.JobID,@.ApplicantID,@.Po
sitionID,@.Version,@.QuestionUnique,
@.A
> nswer,@.AnswerTime)
> else
> Update ftsolutions.dbo.ApplicantScreen set Answer=@.Answer,
> AnswerTime=@.AnswerTime
> where ClientID = @.ClientID and JobID = @.JobID and ApplicantID =
> @.ApplicantID and PositionID = @.PositionID and Version = @.Version
> and QuestionUnique = @.QuestionUnique
> GO
>
> Server: Msg 2715, Level 16, State 3, Procedure AddNewApplicantScreen, Line
> 0
> Column or parameter #2: Cannot find data type bigint.
> Server: Msg 2715, Level 16, State 1, Procedure AddNewApplicantScreen, Line
> 0
> Column or parameter #3: Cannot find data type bigint.
> Parameter '@.JobID' has an invalid data type.
> Parameter '@.ApplicantID' has an invalid data type.
> ****************************************
**********************************
**
> ***
> Here is another:
> ****************************************
**********************************
**
> ***
> CREATE PROCEDURE spAddNewResume
> (
> @.ClientID varChar(20),@.PositionID Int,@.FirstName varChar(30),@.LastName
> varChar(30),@.Email varChar(45),@.TicklerPhrase varChar(45),@.ResumeText
> text,@.CoverSheet text
> )
> AS
> declare @.ApplicantID int, @.JobID bigInt
> if not exists (Select ApplicantID from ftsolutions.dbo.Applicant where
> ClientID = @.ClientID and
> LastName = @.LastName and FirstName = @.FirstName and Email = @.Email)
> begin
> begin tran
> INSERT INTO Applicant
> (ClientID,ApplicantID,PositionID,FirstNa
me,LastName,Email,DatePosted)
> Select
> @.ClientID,COALESCE(max(ApplicantID),1000
)+1,@.PositionID,@.FirstName,
> @.LastName,@.Email,getdate()
> from ftsolutions.dbo.Applicant
> where ClientID = @.ClientID
> Select @.JobID = Scope_Identity()
> Select @.ApplicantID=ApplicantID from ftsolutions.dbo.Applicant where
> JobID
> = @.JobID
> commit tran
> end
> else
> begin
> Select @.ApplicantID = ApplicantID from Applicant where ClientID =
> @.ClientID
> and
> LastName = @.LastName and FirstName = @.FirstName and Email = @.Email
> INSERT INTO Applicant
> (ClientID,ApplicantID,PositionID,FirstNa
me,LastName,Email,DatePosted)
> values
> (@.ClientID,@.ApplicantID,@.PositionID,@.Fir
stName,
> @.LastName,@.Email,getdate() )
> Select @.JobID = Scope_Identity()
> end
> INSERT INTO ApplicantResume
> (ClientID,ApplicantID,PositionID,FirstNa
me,LastName,Email,TicklerPhrase,Re
su
> meText,CoverSheet,JobID) values
> (
> @.ClientID,@.ApplicantID,@.PositionID,@.Firs
tName,@.LastName,@.Email,@.TicklerPhr
as
> e,@.ResumeText,@.CoverSheet,@.JobID)
> INSERT INTO JobApplicant (ClientID,ApplicantID,PositionID,JobID,R
esume)
> Values(@.ClientID,@.ApplicantID,@.PositionI
D,@.JobID,getdate() )
> select @.ApplicantID as ApplicantID,@.JobID as JobID
> GO
>
> Server: Msg 195, Level 15, State 10, Procedure spAddNewResume, Line 17
> 'Scope_Identity' is not a recognized function name.
> Server: Msg 195, Level 15, State 1, Procedure spAddNewResume, Line 29
> 'Scope_Identity' is not a recognized function name.
> ****************************************
**********************************
**
> **
> Why would that happen?
> Thanks,
> Tom
>|||"Dan Guzman" <guzmanda@.nospam-online.sbcglobal.net> wrote in message
news:%233HvNAvGFHA.2360@.TK2MSFTNGP12.phx.gbl...
> What does the following return on your home machine?
> SELECT @.@.VERSION
I couldn't remember how to get the version.
I did have both Sql Server 7 and 2k on my machine, but I now remember I took
the 2k off when testing the trial version and converting to the real version
before I did it at work.
I just reinstalled 2k and it works fine now.
How stupid.
Thanks,
Tom
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "tshad" <tfs@.dslextreme.com> wrote in message
> news:OawFG9uGFHA.3156@.TK2MSFTNGP10.phx.gbl...
use
ApplicantScreen(ClientID,JobID,Applicant
ID,PositionID,Version,QuestionUnique[col
or=darkred]
values(@.ClientID,@.JobID,@.ApplicantID,@.Po
sitionID,@.Version,@.QuestionUnique,@.A[col
or=darkred]
Line
Line
****************************************
************************************[col
or=darkred]
****************************************
************************************[col
or=darkred]
(ClientID,ApplicantID,PositionID,FirstNa
me,LastName,Email,TicklerPhrase,Resu[col
or=darkred]
@.ClientID,@.ApplicantID,@.PositionID,@.Firs
tName,@.LastName,@.Email,@.TicklerPhras[col
or=darkred]
****************************************
************************************[col
or=darkred]
>

Monday, March 12, 2012

Problems with Index Tuning

Hi all,
I'm trying to use SQL Profile and Index tuning to tune performance of my
database.
My Web application use only Stored Procedures.
During the "SQL Profile session" I traced "Stored Procedure RPC:Completed"
as event. Follow and example of trace:
exec sp_executesql N'EXEC SP_SALVAQUADRO_EONERI @.P1, @.P2, @.P3, @.P4, @.P5,
@.P6, @.P7, @.P8 ', N'@.P1 int ,@.P2 tinyint ,@.P3 tinyint ,@.P4 int ,@.P5 tinyint
,@.P6 tinyint ,@.P7 int ,@.P8 int ', 59773, 3, 33, 11, 12, 0, 1239, 1239
exec sp_executesql N'EXEC SP_CARICAQUADRO_A @.P1, @.P2 ', N'@.P1 int ,@.P2
tinyint ', 59774, 3
...
The trace contains several thousands of above commands. The various Stored
Procedure add, modify, delete records on tables that have not indexes.
The second step is to use the registered trace as workload in "Index tuning
wizard".
At the end of the wizard the responce is:
"No index racciomandation for the workload and choosen parameters."
Unfortunately this is false because the database is not indexed and the
Stored Procedure contained in the workload need of indexes.
Anyone can Help ME ?
Best Regards
Alessandro Zucchi (AlessandroZucchi@.discussions.microsoft.com) writes:
> I'm trying to use SQL Profile and Index tuning to tune performance of my
> database.
> My Web application use only Stored Procedures. During the "SQL Profile
> session" I traced "Stored Procedure RPC:Completed" as event. Follow and
> example of trace:
> exec sp_executesql N'EXEC SP_SALVAQUADRO_EONERI @.P1, @.P2, @.P3, @.P4, @.P5,
> @.P6, @.P7, @.P8 ', N'@.P1 int ,@.P2 tinyint ,@.P3 tinyint ,@.P4 int ,@.P5 tinyint
> ,@.P6 tinyint ,@.P7 int ,@.P8 int ', 59773, 3, 33, 11, 12, 0, 1239, 1239
> exec sp_executesql N'EXEC SP_CARICAQUADRO_A @.P1, @.P2 ', N'@.P1 int ,@.P2
> tinyint ', 59774, 3
> ...
> The trace contains several thousands of above commands. The various Stored
> Procedure add, modify, delete records on tables that have not indexes.
> The second step is to use the registered trace as workload in "Index
> tuning wizard".
> At the end of the wizard the responce is:
> "No index racciomandation for the workload and choosen parameters."
> Unfortunately this is false because the database is not indexed and the
> Stored Procedure contained in the workload need of indexes.
I have never used ITW, but obviously the event RPC:Completed is not
enough to trace. I would expect SP:StmtCompleted to be required, as well
as some of the performance events, and possibly some of the Object:Scan
events. I suggest that you study the documenation for the Index Tuning
Wizard.
By the way, the sp_ prefix is reserved for system stored procedures, and
you should not use it for your own objects, as SQL Server first looks
for these in master.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
|||Hi Alessandro
Unfortunately, the Index Tuning Wizard is over-simplistic in its
capabilities. You'll probably have to do this work manually by identifying
which stored procedure (or few worst stored procedures) is actually the
worst performing procedure & then tuning that stored procedure/s.
This, however is far easier to say than to do, as aggregating the
information you collect from your profiler traces is no trivial task.
I wrote an application SQLBenchmarkPro, which has this capability & it's
available for free to test at the moment from www.gajsoftware.com . It's
really designed for streamlining on-going SQL Server benchmark work, but it
also has an analysis feature whiich will capture profiler events, aggregate
them & tell you which are the worst performing stored procs to help you
focus your efforts. This is the easiest way I know of to perform this work
when the Index Tuning Wizard isn't up to the job.
HTH
Regards,
Greg Linwood
SQL Server MVP
"Alessandro Zucchi" <AlessandroZucchi@.discussions.microsoft.com> wrote in
message news:0D740F5D-78B3-4417-A53C-3311E01C7F76@.microsoft.com...
> Hi all,
> I'm trying to use SQL Profile and Index tuning to tune performance of my
> database.
> My Web application use only Stored Procedures.
> During the "SQL Profile session" I traced "Stored Procedure
> RPC:Completed"
> as event. Follow and example of trace:
> exec sp_executesql N'EXEC SP_SALVAQUADRO_EONERI @.P1, @.P2, @.P3, @.P4, @.P5,
> @.P6, @.P7, @.P8 ', N'@.P1 int ,@.P2 tinyint ,@.P3 tinyint ,@.P4 int ,@.P5 tinyint
> ,@.P6 tinyint ,@.P7 int ,@.P8 int ', 59773, 3, 33, 11, 12, 0, 1239, 1239
> exec sp_executesql N'EXEC SP_CARICAQUADRO_A @.P1, @.P2 ', N'@.P1 int ,@.P2
> tinyint ', 59774, 3
> ...
> The trace contains several thousands of above commands. The various Stored
> Procedure add, modify, delete records on tables that have not indexes.
> The second step is to use the registered trace as workload in "Index
> tuning
> wizard".
> At the end of the wizard the responce is:
> "No index racciomandation for the workload and choosen parameters."
> Unfortunately this is false because the database is not indexed and the
> Stored Procedure contained in the workload need of indexes.
> Anyone can Help ME ?
> Best Regards

Friday, March 9, 2012

Problems with debugging remotely SQLCLR stored procedures?

Hello,

my username is se\levalencia, I had before the database on my machine, but as now we have a server I backed up the database and restored on the server, it seems that it has the sames logins and security users,

Its strange because the user dbo is assigned the user se\levalencia on the server, and I cant alter the user dbo.

The user dbo should be the login sa? I am in big trouble with this, beacuase I cant debug my sql clr stored procedure.

T-Sql execution ended without debugging. You may have not have sufficient permissions to debug.

I am using a connection with windows authentication, so it means that its sending tha tokes as se\levalencia to the server.

Please feel free to ask for more information about it. Thanks

More strange yet, I just changed the connection and put SA as the user which executes the sql clr stored procedure, I got the same problem, its supposed to be a super user.

|||

You would need to add se\levalencia as a member of sysadmin role on the server. For debugging T-SQL as well as SQLCLR the debugger needs to run under an account that is a member of sysadmin role on SQL Server.

Thanks,

-Vineet.

Problems with debugging remotely SQLCLR stored procedures?

Hello,

my username is se\levalencia, I had before the database on my machine, but as now we have a server I backed up the database and restored on the server, it seems that it has the sames logins and security users,

Its strange because the user dbo is assigned the user se\levalencia on the server, and I cant alter the user dbo.

The user dbo should be the login sa? I am in big trouble with this, beacuase I cant debug my sql clr stored procedure.

T-Sql execution ended without debugging. You may have not have sufficient permissions to debug.

I am using a connection with windows authentication, so it means that its sending tha tokes as se\levalencia to the server.

Please feel free to ask for more information about it. Thanks

More strange yet, I just changed the connection and put SA as the user which executes the sql clr stored procedure, I got the same problem, its supposed to be a super user.

|||

You would need to add se\levalencia as a member of sysadmin role on the server. For debugging T-SQL as well as SQLCLR the debugger needs to run under an account that is a member of sysadmin role on SQL Server.

Thanks,

-Vineet.

Wednesday, March 7, 2012

Problems With Create Table #nametable

Hello
I' ve problems with the instruction Create Table #TableName, because days
ago I was run store procedures with this instruction and i don't problems.
the result is ok!.
I don' t know now why i can't run this stores...
Not exists alteration in nothing with respect to Data Base.. no new fields,
nothing.
Thanks and regards
PD: When I use Declare @.tableName Table, all is ok. WHY?, I need use
#TableName because I use "Execute('Senteces')" and "Sentences" is a string
concatenate . I like know why?
Can you define "problems"? Can you show the code, and what happens (e.g.
the error message)?
http://www.aspfaq.com/
(Reverse address to reply.)
"Table, Declare Table, Create table, SP" <Table, Declare Table, Create
table, SP@.discussions.microsoft.com> wrote in message
news:0C7AB68F-3102-4EB9-B74A-D9626B2FE45F@.microsoft.com...
> Hello
> I' ve problems with the instruction Create Table #TableName, because days
> ago I was run store procedures with this instruction and i don't problems.
> the result is ok!.
> I don' t know now why i can't run this stores...
> Not exists alteration in nothing with respect to Data Base.. no new
fields,
> nothing.
> Thanks and regards
> PD: When I use Declare @.tableName Table, all is ok. WHY?, I need use
> #TableName because I use "Execute('Senteces')" and "Sentences" is a
string
> concatenate . I like know why?
|||Before :
Create table #tmp_Articulos_Vencidos
(cod_Articulovarchar(20)COLLATE Modern_Spanish_CI_AS,
Saldo_Lote decimal(15,5)
)
insert into #tmp_Articulos_Vencidos
SelectArt.Cod_Articulo_Auxas cod_Articulo,
cast(sum(isnull(TEAL.num_stock_saldo_lote,0)) as decimal(15,5)) as Saldo_Lote
Fromtab_existencias_almacenas teawith (nolock)
Jointab_Articuloas Artwith (nolock)
OnArt.Cod_Catalogo= Tea.Cod_Catalogo
AndArt.Cod_Articulo= Tea.Cod_Articulo
AndArt.fla_reg_lote= 'S'
Left
jointab_existencias_almacen_loteas TEALwith (nolock)
OnTEAL.Cod_Pais= Tea.Cod_Pais
AndTEAL.Cod_Almacen= Tea.Cod_Almacen
AndTEAL.Cod_Articulo= Tea.Cod_Articulo
AndTEAL.Cod_Catalogo= Tea.Cod_Catalogo
Where
Tea.Cod_pais= @.Cod_pais
andAlm.Cod_Terra= @.Cod_Terra
Group by
Art.Cod_Articulo_Aux,
teal.fec_vencimiento
-- -*-*-*-*-*-*-*-*-*-*-*
-- Show results
-- -*-*-*-*-*-*-*-*-*-*-*
Execute('Select cod_Articuloas [Código], ' +
'Saldo_loteas [Stock] ' +
'From#tmp_Articulos_Vencidos ' +
'Where (1=1) ' +
'Order by 2 ' )
drop table #tmp_Articulos_Vencidos
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
After :
SelectArt.Cod_Articulo_Auxas cod_Articulo,
cast(sum(isnull(TEAL.num_stock_saldo_lote,0)) as decimal(15,5)) as Saldo_Lote
INTO #tmp_Articulos_Vencidos
Fromtab_existencias_almacenas teawith (nolock)
Jointab_Articuloas Artwith (nolock)
OnArt.Cod_Catalogo= Tea.Cod_Catalogo
AndArt.Cod_Articulo= Tea.Cod_Articulo
AndArt.fla_reg_lote= 'S'
Left
jointab_existencias_almacen_loteas TEALwith (nolock)
OnTEAL.Cod_Pais= Tea.Cod_Pais
AndTEAL.Cod_Almacen= Tea.Cod_Almacen
AndTEAL.Cod_Articulo= Tea.Cod_Articulo
AndTEAL.Cod_Catalogo= Tea.Cod_Catalogo
Where
Tea.Cod_pais= @.Cod_pais
andAlm.Cod_Terra= @.Cod_Terra
Group by
Art.Cod_Articulo_Aux,
teal.fec_vencimiento
-- -*-*-*-*-*-*-*-*-*-*-*
-- Show results
-- -*-*-*-*-*-*-*-*-*-*-*
Execute('Select cod_Articuloas [Código], ' +
'Saldo_loteas [Stock] ' +
'From#tmp_Articulos_Vencidos ' +
'Where (1=1) ' +
'Order by 2 ' )
drop table #tmp_Articulos_Vencidos
QUESTION : ????
Why ?, before it success ok. and now NOT...
thanks
"Aaron [SQL Server MVP]" wrote:

> Can you define "problems"? Can you show the code, and what happens (e.g.
> the error message)?
> --
> http://www.aspfaq.com/
> (Reverse address to reply.)
>
>
> "Table, Declare Table, Create table, SP" <Table, Declare Table, Create
> table, SP@.discussions.microsoft.com> wrote in message
> news:0C7AB68F-3102-4EB9-B74A-D9626B2FE45F@.microsoft.com...
> fields,
> string
>
>
|||> Why ?, before it success ok. and now NOT...
What does this mean? Do you get an error message? If so, what is it? If
not, what does "success NOT" mean?

Problems With Create Table #nametable

Hello
I' ve problems with the instruction Create Table #TableName, because days
ago I was run store procedures with this instruction and i don't problems.
the result is ok!.
I don' t know now why i can't run this stores...
Not exists alteration in nothing with respect to Data Base.. no new fields,
nothing.
Thanks and regards
PD: When I use Declare @.tableName Table, all is ok. WHY?, I need use
#TableName because I use "Execute('Senteces')" and "Sentences" is a string
concatenate . I like know why?Can you define "problems"? Can you show the code, and what happens (e.g.
the error message)?
http://www.aspfaq.com/
(Reverse address to reply.)
"Table, Declare Table, Create table, SP" <Table, Declare Table, Create
table, SP@.discussions.microsoft.com> wrote in message
news:0C7AB68F-3102-4EB9-B74A-D9626B2FE45F@.microsoft.com...
> Hello
> I' ve problems with the instruction Create Table #TableName, because days
> ago I was run store procedures with this instruction and i don't problems.
> the result is ok!.
> I don' t know now why i can't run this stores...
> Not exists alteration in nothing with respect to Data Base.. no new
fields,
> nothing.
> Thanks and regards
> PD: When I use Declare @.tableName Table, all is ok. WHY?, I need use
> #TableName because I use "Execute('Senteces')" and "Sentences" is a
string
> concatenate . I like know why?|||Before :
Create table #tmp_Articulos_Vencidos
(cod_Articulo varchar(20) COLLATE Modern_Spanish_CI_AS,
Saldo_Lote decimal(15,5)
)
insert into #tmp_Articulos_Vencidos
Select Art.Cod_Articulo_Aux as cod_Articulo,
cast(sum(isnull(TEAL.num_stock_saldo_lote,0)) as decimal(15,5)) as Saldo_Lot
e
From tab_existencias_almacen as tea with (nolock)
Join tab_Articulo as Art with (nolock)
On Art.Cod_Catalogo = Tea.Cod_Catalogo
And Art.Cod_Articulo = Tea.Cod_Articulo
And Art.fla_reg_lote = 'S'
Left
join tab_existencias_almacen_lote as TEAL with (nolock)
On TEAL.Cod_Pais = Tea.Cod_Pais
And TEAL.Cod_Almacen = Tea.Cod_Almacen
And TEAL.Cod_Articulo = Tea.Cod_Articulo
And TEAL.Cod_Catalogo = Tea.Cod_Catalogo
Where
Tea.Cod_pais = @.Cod_pais
and Alm.Cod_Terra = @.Cod_Terra
Group by
Art.Cod_Articulo_Aux,
teal.fec_vencimiento
-- -*-*-*-*-*-*-*-*-*-*-*
-- Show results
-- -*-*-*-*-*-*-*-*-*-*-*
Execute ('Select cod_Articulo as [Código], ' +
' Saldo_lote as [Stock] ' +
'From #tmp_Articulos_Vencidos ' +
'Where (1=1) ' +
'Order by 2 ' )
drop table #tmp_Articulos_Vencidos
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
After :
Select Art.Cod_Articulo_Aux as cod_Articulo,
cast(sum(isnull(TEAL.num_stock_saldo_lote,0)) as decimal(15,5)) as Saldo_Lot
e
INTO #tmp_Articulos_Vencidos
From tab_existencias_almacen as tea with (nolock)
Join tab_Articulo as Art with (nolock)
On Art.Cod_Catalogo = Tea.Cod_Catalogo
And Art.Cod_Articulo = Tea.Cod_Articulo
And Art.fla_reg_lote = 'S'
Left
join tab_existencias_almacen_lote as TEAL with (nolock)
On TEAL.Cod_Pais = Tea.Cod_Pais
And TEAL.Cod_Almacen = Tea.Cod_Almacen
And TEAL.Cod_Articulo = Tea.Cod_Articulo
And TEAL.Cod_Catalogo = Tea.Cod_Catalogo
Where
Tea.Cod_pais = @.Cod_pais
and Alm.Cod_Terra = @.Cod_Terra
Group by
Art.Cod_Articulo_Aux,
teal.fec_vencimiento
-- -*-*-*-*-*-*-*-*-*-*-*
-- Show results
-- -*-*-*-*-*-*-*-*-*-*-*
Execute ('Select cod_Articulo as [Código], ' +
' Saldo_lote as [Stock] ' +
'From #tmp_Articulos_Vencidos ' +
'Where (1=1) ' +
'Order by 2 ' )
drop table #tmp_Articulos_Vencidos
QUESTION : ????
Why ?, before it success ok. and now NOT...
thanks
"Aaron [SQL Server MVP]" wrote:

> Can you define "problems"? Can you show the code, and what happens (e.g.
> the error message)?
> --
> http://www.aspfaq.com/
> (Reverse address to reply.)
>
>
> "Table, Declare Table, Create table, SP" <Table, Declare Table, Create
> table, SP@.discussions.microsoft.com> wrote in message
> news:0C7AB68F-3102-4EB9-B74A-D9626B2FE45F@.microsoft.com...
> fields,
> string
>
>|||> Why ?, before it success ok. and now NOT...
What does this mean? Do you get an error message? If so, what is it? If
not, what does "success NOT" mean?

Problems With Create Table #nametable

Hello
I' ve problems with the instruction Create Table #TableName, because days
ago I was run store procedures with this instruction and i don't problems.
the result is ok!.
I don' t know now why i can't run this stores...
Not exists alteration in nothing with respect to Data Base.. no new fields,
nothing.
Thanks and regards
PD: When I use Declare @.tableName Table, all is ok. WHY?, I need use
#TableName because I use "Execute('Senteces')" and "Sentences" is a string
concatenate . I like know why?Can you define "problems"? Can you show the code, and what happens (e.g.
the error message)?
--
http://www.aspfaq.com/
(Reverse address to reply.)
"Table, Declare Table, Create table, SP" <Table, Declare Table, Create
table, SP@.discussions.microsoft.com> wrote in message
news:0C7AB68F-3102-4EB9-B74A-D9626B2FE45F@.microsoft.com...
> Hello
> I' ve problems with the instruction Create Table #TableName, because days
> ago I was run store procedures with this instruction and i don't problems.
> the result is ok!.
> I don' t know now why i can't run this stores...
> Not exists alteration in nothing with respect to Data Base.. no new
fields,
> nothing.
> Thanks and regards
> PD: When I use Declare @.tableName Table, all is ok. WHY?, I need use
> #TableName because I use "Execute('Senteces')" and "Sentences" is a
string
> concatenate . I like know why?|||Before :
Create table #tmp_Articulos_Vencidos
(cod_Articulo varchar(20) COLLATE Modern_Spanish_CI_AS,
Saldo_Lote decimal(15,5)
)
insert into #tmp_Articulos_Vencidos
Select Art.Cod_Articulo_Aux as cod_Articulo,
cast(sum(isnull(TEAL.num_stock_saldo_lote,0)) as decimal(15,5)) as Saldo_Lote
From tab_existencias_almacen as tea with (nolock)
Join tab_Articulo as Art with (nolock)
On Art.Cod_Catalogo = Tea.Cod_Catalogo
And Art.Cod_Articulo = Tea.Cod_Articulo
And Art.fla_reg_lote = 'S'
Left
join tab_existencias_almacen_lote as TEAL with (nolock)
On TEAL.Cod_Pais = Tea.Cod_Pais
And TEAL.Cod_Almacen = Tea.Cod_Almacen
And TEAL.Cod_Articulo = Tea.Cod_Articulo
And TEAL.Cod_Catalogo = Tea.Cod_Catalogo
Where
Tea.Cod_pais = @.Cod_pais
and Alm.Cod_Terra = @.Cod_Terra
Group by
Art.Cod_Articulo_Aux,
teal.fec_vencimiento
-- -*-*-*-*-*-*-*-*-*-*-*
-- Show results
-- -*-*-*-*-*-*-*-*-*-*-*
Execute ('Select cod_Articulo as [Código], ' +
' Saldo_lote as [Stock] ' +
'From #tmp_Articulos_Vencidos ' +
'Where (1=1) ' +
'Order by 2 ' )
drop table #tmp_Articulos_Vencidos
--
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
After :
Select Art.Cod_Articulo_Aux as cod_Articulo,
cast(sum(isnull(TEAL.num_stock_saldo_lote,0)) as decimal(15,5)) as Saldo_Lote
INTO #tmp_Articulos_Vencidos
From tab_existencias_almacen as tea with (nolock)
Join tab_Articulo as Art with (nolock)
On Art.Cod_Catalogo = Tea.Cod_Catalogo
And Art.Cod_Articulo = Tea.Cod_Articulo
And Art.fla_reg_lote = 'S'
Left
join tab_existencias_almacen_lote as TEAL with (nolock)
On TEAL.Cod_Pais = Tea.Cod_Pais
And TEAL.Cod_Almacen = Tea.Cod_Almacen
And TEAL.Cod_Articulo = Tea.Cod_Articulo
And TEAL.Cod_Catalogo = Tea.Cod_Catalogo
Where
Tea.Cod_pais = @.Cod_pais
and Alm.Cod_Terra = @.Cod_Terra
Group by
Art.Cod_Articulo_Aux,
teal.fec_vencimiento
-- -*-*-*-*-*-*-*-*-*-*-*
-- Show results
-- -*-*-*-*-*-*-*-*-*-*-*
Execute ('Select cod_Articulo as [Código], ' +
' Saldo_lote as [Stock] ' +
'From #tmp_Articulos_Vencidos ' +
'Where (1=1) ' +
'Order by 2 ' )
drop table #tmp_Articulos_Vencidos
QUESTION : ¿¿¿?
Why ?, before it success ok. and now NOT...
thanks
"Aaron [SQL Server MVP]" wrote:
> Can you define "problems"? Can you show the code, and what happens (e.g.
> the error message)?
> --
> http://www.aspfaq.com/
> (Reverse address to reply.)
>
>
> "Table, Declare Table, Create table, SP" <Table, Declare Table, Create
> table, SP@.discussions.microsoft.com> wrote in message
> news:0C7AB68F-3102-4EB9-B74A-D9626B2FE45F@.microsoft.com...
> > Hello
> >
> > I' ve problems with the instruction Create Table #TableName, because days
> > ago I was run store procedures with this instruction and i don't problems.
> > the result is ok!.
> >
> > I don' t know now why i can't run this stores...
> >
> > Not exists alteration in nothing with respect to Data Base.. no new
> fields,
> > nothing.
> >
> > Thanks and regards
> >
> > PD: When I use Declare @.tableName Table, all is ok. WHY?, I need use
> > #TableName because I use "Execute('Senteces')" and "Sentences" is a
> string
> > concatenate . I like know why?
>
>|||> Why ?, before it success ok. and now NOT...
What does this mean? Do you get an error message? If so, what is it? If
not, what does "success NOT" mean?