Function Error (newbie)

Jun 16, 2007

eh guys ma kind of newbie n tis ... k like wrote a function like

CREATE FUNCTION [dbo].[GetDetailText]
{
@PackingID int,
@PackingType int
}
RETURNS varchar(100)


AS

BEGIN

DECLARE @DetailText varchar(100)

IF (@PackingType = 1)
BEGIN


SET @DetailText = (SELECT
'Tickness' + ':' + CONVERT(varchar, dbo.KF_PackMaterial.thickness) + '' + CONVERT(varchar, KF_Unit_3.Symbol)
+ ',' + 'Width' + ': ' + CONVERT(varchar, dbo.KF_PackMaterial.width) + '' + CONVERT(varchar, KF_Unit_1.Symbol)
+ ',' + 'InnerDia' + ':' + CONVERT(varchar, dbo.KF_PackMaterial.india) + '' + CONVERT(varchar, KF_Unit_5.Symbol)
+ ',' + 'OuterDia' + ':' + CONVERT(varchar, dbo.KF_PackMaterial.outdia) + '' + CONVERT(varchar, KF_Unit_6.Symbol)
+ ',' + 'Recycle' + ':' + CONVERT(varchar, dbo.KF_PackMaterial.recycle) + ', ' + 'Shade' + ':' + CONVERT(varchar, dbo.KF_PackMaterial.shade)
+ ',' + 'Weight' + ':' + CONVERT(varchar, dbo.KF_PackMaterial.weight) + '' + CONVERT(varchar, KF_Unit_4.Symbol)
+ ',' + 'Perforation' + ':' + CONVERT(varchar, dbo.KF_PackMaterial.perforation) + ' (' + CONVERT(varchar, dbo.KF_PackingMaterial.PackingTypeName)
+ ')'
FROM dbo.KF_CartonImageList RIGHT OUTER JOIN
dbo.KF_PackMaterial INNER JOIN
dbo.KF_PackType ON dbo.KF_PackMaterial.type = dbo.KF_PackType.PackID INNER JOIN
dbo.KF_Unit KF_Unit_1 ON dbo.KF_PackMaterial.widthunit = KF_Unit_1.UnitID INNER JOIN
dbo.KF_PackingMaterial ON dbo.KF_PackMaterial.packmaterialid = dbo.KF_PackingMaterial.Packingid LEFT OUTER JOIN
dbo.KF_Color ON dbo.KF_PackMaterial.ColorId = dbo.KF_Color.ColorId LEFT OUTER JOIN
dbo.KF_Unit KF_Unit_6 ON dbo.KF_PackMaterial.outdiaunit = KF_Unit_6.UnitID LEFT OUTER JOIN
dbo.KF_Unit KF_Unit_5 ON dbo.KF_PackMaterial.indiaunit = KF_Unit_5.UnitID LEFT OUTER JOIN
dbo.KF_Unit KF_Unit_4 ON dbo.KF_PackMaterial.weightunit = KF_Unit_4.UnitID LEFT OUTER JOIN
dbo.KF_Unit KF_Unit_3 ON dbo.KF_PackMaterial.thicknessunit = KF_Unit_3.UnitID LEFT OUTER JOIN
dbo.KF_Unit KF_Unit_2 ON dbo.KF_PackMaterial.lengthunit = KF_Unit_2.UnitID LEFT OUTER JOIN
dbo.KF_Unit KF_Unit_7 ON dbo.KF_PackMaterial.heightunit = KF_Unit_7.UnitID ON
dbo.KF_CartonImageList.CDImageId = dbo.KF_PackMaterial.CDImageId
WHERE (dbo.KF_PackMaterial.id=@PackingID AND dbo.KF_PackMaterial.packmaterialid=@PackingType))
END

return @DetailText
END


buts its throwing syntax error like
"[Microsoft][ODBC SQL Server Driver]Syntax error or access violation
"

... ne idea ????????

View 3 Replies


ADVERTISEMENT

Newbie Here With A Newbie Error - Getting Database ... Already Exists.

Feb 24, 2007

Hi there
I sorry if I have placed this query in the wrong place.
I'm getting to grips with ASP.net 2, slowly but surely! 
When i try to access my site which uses a Sql Server 2005 express DB i am receiving the following error:

Server Error in '/jarebu/site1' Application.


Database 'd:hostingmemberasangaApp_DataASPNETDB.mdf' already exists.Could not attach file 'd:hostingmemberjarebusite1App_DataASPNETDB.MDF' as database 'ASPNETDB'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Database 'd:hostingmemberasangaApp_DataASPNETDB.mdf' already exists.Could not attach file 'd:hostingmemberjarebusite1App_DataASPNETDB.MDF' as database 'ASPNETDB'.Source Error:



An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace:



[SqlException (0x80131904): Database 'd:hostingmemberasangaApp_DataASPNETDB.mdf' already exists.
Could not attach file 'd:hostingmemberjarebusite1App_DataASPNETDB.MDF' as database 'ASPNETDB'.]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +735075
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1838
System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +33
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +628
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +170
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +359
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +28
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +424
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +496
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +82
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +105
System.Data.SqlClient.SqlConnection.Open() +111
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +121
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +137
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +83
System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1770
System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +17
System.Web.UI.WebControls.DataBoundControl.PerformSelect() +149
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70
System.Web.UI.WebControls.GridView.DataBind() +4
System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82
System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +69
System.Web.UI.Control.EnsureChildControls() +87
System.Web.UI.Control.PreRenderRecursiveInternal() +41
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1360



Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210
 
 This is the connection string that I am using:
 <connectionStrings>
<add name="ConnectionString" connectionString="Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|ASPNETDB.MDF;Integrated Security=True;Initial Catalog=ASPNETDB;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
 
The database is definitly in the folder that the error message relates to.
What I'm finding confusing is that the connection string seems to be finding "aranga"s database.
Is it something daft?
 
Many thanks.
James 

View 1 Replies View Related

Newbie Question: Header Textbox = Function Return

Dec 5, 2007



I've got a user-defined function that I'd like to call and return a string to a textbox that is in my header.
The rows of the report are working with with a select statement.
I have something that I'd like to have in the header and am not sure how to get it.

In the properties of the textbox, I tried =dbo.udf_myfunction(), but that didn't work.
So how do you assign the textbox value from a user-defined function?

View 5 Replies View Related

Newbie Need Help. Export Error, Null Value Error.

Sep 24, 2004

Hey all,

I'm currently using a shopping cart software called .netCart, which is in ASP.NET and VB. I have been trying to import my local "fully working" database to my remote server using Enterprise Manager via the DTS Export/Import Wizard, but then the exported remote database is not working with the software. Unfortunately, I have no prior experiences in MS SQL database at all, nor do I know anything about the scripts they used with the software I purchased.

Error message when attempting to run part of the software (website) with the exported database -

"Cannot insert the value NULL into column 'CustomerID', table 'tablename.dbo.Customers'; column does not allow nulls. INSERT fails. The statement has been terminated. [Customer Table]"

I simply used the DTS wizard to export the database. All settings are left "default" because I don't know what I should do about them....

1) At Specify Table Copy or Quert, "Copy table(s) and view(s) from the source database is selected.
2) Selected all tables. At the "Column Mappings and Transformations" window for all tables, "Create detination table" is SELECTED and "Enable identify insert" is UNCHECKED.
3) At one of the error table (i.e. Customers), the CustomerID int is NOT NULL.

Sorry, I do not know what's wrong with it, and I don't know how to explain it better technically. The software company do not support this as well.

I believe the problem is with the settings in the DTS wizard when I try to export the database. Something is not set right, but I don't know how to do it.

Can anyone please try to solve this problem for me? Thank you very much.

Temjin

View 2 Replies View Related

Newbie Error

Apr 13, 2004

Hi guys,
Your help please.
First off, I have searched the Forum for answers using the keywords and tried those clues first but with no luck. This one for example: http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q282254

I had a copy of MSDE installed on my machine about 12 month ago but never used it so I uninstalled it. Then I downloaded and installed SQL Server 120-day Evaluation edition a few days ago. When I tried to run SQL Server I get
An error 1069 – (The service did not start due to logon failure)…

I’m using Windows XP.

How can I find out what the password is or how can I reset it so the SQL Server logon works?

Any ideas?

Thanks Guys


FB

View 3 Replies View Related

Newbie Error? Crosstable Query

Mar 30, 2005

I'm struggling with the problem which feels like it shouldn't be taking me this long! Any help would be gratefully received. Simply, there are two tables: Users: userid | username Links: sourceUserId | destUserId sourceUserId and destUserId are both in the users table. I'm trying to write a SP which will output the names of the linked users. eg: Bob | Alice Alice | Geoffrey Peter | Bob Any help gratefully received! Thanks in advance -- Chris

View 2 Replies View Related

Newbie Help: SQL Server Does Not Exist Error

Nov 23, 2004

I've seen this question asked when I searched, but I didn't see an answer that looked like it applied to me, so I'll ask again.....

Making the transition from VB 6 to VB.NET and decided to take a stab at database programming while I'm at it. I bought "Database Programming with Visual Basic.NET and ADO.NET" by Sams Publishing and ran into problems in the first chapter. I've posted some questions on the microsoft.public.vb.database newsgroup and got some help, but it's still not working.

I'll skip some of the boring stuff and dive right in with what I've found out so far:

From MSSQL$VSDOTNETLOGERRORLOG

2004-11-19 02:29:34.71 spid3 SQL global counter collection task is created.
2004-11-19 02:29:34.76 spid3 Warning: override, autoexec procedures skipped.
2004-11-19 02:29:58.87 spid51 Error: 15457, Severity: 0, State: 1
2004-11-19 02:29:58.87 spid51 Configuration option 'allow updates' changed from 0 to 1. Run the RECONFIGURE statement to install..
2004-11-19 02:29:59.01 spid51 Error: 15457, Severity: 0, State: 1
2004-11-19 02:29:59.01 spid51 Configuration option 'allow updates' changed from 1 to 0. Run the RECONFIGURE statement to install..
2004-11-19 02:29:59.46 spid3 SQL Server is terminating due to 'stop' request from Service Control Manager.

The last suggestion was to uninstall and reinstall. I uninstalled VS and SQL and reinstalled getting the same error message in the log, but the message box said that installation was complete.

On the Server Explorer of the IDE, it shows my computers name (programmer) under Servers. When I expand that and expand SQL Servers, I see PROGRAMMERVSDOTNET. When I try to expand that, I get the SQL Server Login window with Server textbox disabled saying PROGRAMMERVSDOTNET and the Database blank. Under the Login it has James (my sign in name) and asks for a password. When I did the MS-DOS CLI installation, I used "password" as the SAPWD. I tried using password, and tried using the password to log on as James, and get the same error message: [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.

Any help would be appreciated, as long as you remember that I am a COMPLETE newbie at this. I'm fairly computer literate, but I don't know the first thing about databases.....

Thanks again,

James

View 3 Replies View Related

Newbie: Error-message Question

May 16, 2006

I got the error message: "The metadata of the following output columns does not match the metadata of the external columns with which the output columns are associated". What does that mean and how am I supposed to fix the problem?



TIA,

Barker

P.S. The SSIS UI seems extremely slow and sluggish (opening, creating connections). Any performance tweaks known? (I have 9GB of RAM on my box and plenty of HD space so I don't think that is it. I also have sql 2005, sp1 installed.)



View 2 Replies View Related

Newbie - Sa Password Error After ACT! Install - Need Pro's Help!!!

Aug 16, 2006

Hello,
I am admittedly new to this, especially sql server and am in need of a pro's assistance.. I installed Microsoft Small Business accounting, which in turn installed and configured a sql server. When I installed ACT! 2005 (v7.0) and tried to create a database, it states that it cannot find the master file.... so I tried to install sql server from Microsofts site - downloaded all the packages, unzipped them and ran them... the error I get is that the sql server needs to have an sa password and to use some switch to change it... for the life of me I am lost here. I can't use ACT! at this point and I have not ideas of how to remove, reinstall or repair the sql server.... Any help you can provide would be greatly appreicated!

View 9 Replies View Related

Newbie Question: Error 9002

May 4, 2007

I'm getting the following msg.



Server: Msg 9002, Level 17, State 2, Procedure spPFW_Get_Financial_Data, Line 145
[Microsoft][ODBC SQL Server Driver][SQL Server]The log file for database 'tempdb' is full. Back up the transaction log for the database to free up some log space.



When I use the tools/backup database it will not let me select backup transaction log or fails the bacup of the tempdb database with a msg saying : 'Backup and restore operations are not allowed on database tempdb'



What should I do?

View 5 Replies View Related

Newbie To SQL. Error Connecting To Server

Sep 27, 2007

hy.
i am a newbie to SQL

i downloaded and installed SQL SERVER 2005 EXPRESS.
i tried to convert an "ACCESS" database to sql and got the next error:

: "AN ERROR OCCURED
WHILE ESTABLIDHING A CONNECTION TO THE SERVER. WHEN CONNECTING TO SQL 2005,
THIS FALIURE MAY BE COUSED BY THE FACT THAT UNDER THE DEFAULT SETTINGS SQL
SERVER DOES NOT ALLOW REMOTE CONNECTIONS. PROVIDOR NAMED PIPES ERROR 40 -
COULD NOT OPEN A CONNECTION TO SQL SERVER".

any help apreaciated.

View 1 Replies View Related

Newbie With An Easy Compilation Error Question.

Dec 30, 2003

I've been looking over this and can't see anything wrong. Can anyone shed some light on this for me?
------------------

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0117: 'System.Data.SqlClient.SqlConnection' does not contain a definition for 'ExecuteReader'

Source Error:



Line 16: SqlCommand myComm = new SqlCommand("SELECT users, password FROM users WHERE username='" + username + "' AND password='" + password + "'", myConn);
Line 17: myConn.Open();
Line 18: SqlDataReader myReader = myConn.ExecuteReader();
Line 19: do
Line 20: {


Source File: D:Inetpubhoteladvisor estLogin.aspx Line: 18


void Login(string username, string password)
{
SqlConnection myConn = new SqlConnection ("server = client1; uid = dbadmin; pwd = dbadmin; database = hotels");
SqlCommand myComm = new SqlCommand("SELECT users, password FROM users WHERE username='" + username + "' AND password='" + password + "'", myConn);
myConn.Open();
SqlDataReader myReader = myConn.ExecuteReader();
do
{
while (reader.Read())
{
if (username == myReader.GetString(1) && password == myReader.GetString(2))
{
messages.Text = "Your login was successful!";
}
else
{
messages.Text = " Your login was unsuccessful!";
}
}
}
while (reader.NextResult());
myReader.Close();
myConn.Close();
}
void Submit_Click(Object sender, EventArgs e)
{
Login(username.Text, password.Text);
}


Edit by moderator - NetProfit: Added < code>< /code> tags.

View 7 Replies View Related

Error While Creating Inline Function - CREATE FUNCTION Failed Because A Column Name Is Not Specified For Column 1.

Apr 3, 2007



Hi,



I am trying to create a inline function which is listed below.



USE [Northwind]

SET ANSI_NULLS ON

GO

CREATE FUNCTION newIdentity()

RETURNS TABLE

AS

RETURN

(SELECT ident_current('orders'))

GO



while executing this function in sql server 2005 my get this error

CREATE FUNCTION failed because a column name is not specified for column 1.



Pleae help me to fix this error



thanks

Purnima

View 3 Replies View Related

Function Error

May 21, 2008

what is the error in that function, please help to find out

create function [dbo].[ufn_IsLeapYear] ( @pDate DATETIME) returns bit
as
begin
declare @b bit


if (YEAR(@pDate)%4=0 ) AND YEAR(@pDate)%100 != 0))
set @b = 1
else if (YEAR(@pDate) % 400 = 0)
set @b= 0
Return(@b)
end


spatle

View 1 Replies View Related

Error With Max Function

Jun 8, 2014

I have the following SQL:

SELECT
MAX(Case WHEN A2.AttrID = '23' AND A2.DefID = '9719132' THEN (Select Name from kua where ID=A2.Valint) END) as Manage
FROM ree A1 inner join data A2 on A1.DataID=A2.ID
AND
A1.SubType=31066
inner join ancestors AN ON AN.DataID = A1.DataID and AN.AncestorID=9735190

Every time I run it i get this error:Cannot perform an aggregate function on an expression containing an aggregate or a subquery...If I change the Field definition to:

MAX(Case WHEN A2.AttrID = '23' AND A2.DefID = '9719132' THEN (A2.Valint) END) as Manager

then it works. The query Select Name from kua where ID=A2.Valint has only one field as result. Why do I get an error?

View 3 Replies View Related

Where Is Error In My Function

Jul 23, 2007

dear folks,
please check my function i'm getting error like this

Select statements included within a function cannot return data to a client.

create function getuomid(@uomcode varchar(50))
returns varchar
as begin
declare @uom_id varchar(50)
select uom_id from vuom where uom_code=@uomcode
return @uom_id
end
go

Vinod
Even you learn 1%, Learn it with 100% confidence.

View 5 Replies View Related

Where Is Error In My Function

Jul 24, 2007

Dear experts,
please tell me where is the error in my code?

create function getitemid(@uomid varchar(50))
returns table
as begin
declare @itemid varchar(50)
select @itemid= column01 from table21 where column03=(select dbo.getuomid('no of leaves'))
return (@itemid)
end
go

Vinod
Even you learn 1%, Learn it with 100% confidence.

View 8 Replies View Related

Error When Using SUM Function

Feb 1, 2008

Hi,
I am write one storedprocedure,inside that i use sum function like
SUM((CASE WHEN d_end_name_qualifier LIKE 'Oc' THEN duration ELSE 0 END)) d_to_stream
then i get following error,

[Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionCheckForData (CheckforData()).
Server: Msg 11, Level 16, State 1, Line 0
General network error. Check your network documentation.

Connection Broken

Dnyaneshwar Bhamare

View 5 Replies View Related

Error With MAX Function

Mar 17, 2008

With this statement I get an error where "Column QuoteHeaderID does not belong to table. " because Object reference isn't being set to an instance of an object, yet if I remove the max part it functions correctly.



Code Snippet
string num1 = "";
string sqlString = "SELECT MAX(QuoteHeaderID) FROM QuoteHeader";
try
{
cmd = new OleDbCommand(sqlString, connectCmd);
cmd.Connection.Open();
cmd.ExecuteNonQuery();
oleDbDataAdapter = new OleDbDataAdapter(cmd);
oleDbDataAdapter.Fill(dt);
if (dt.Rows.Count > 0)
{
num1 = dt.Rows[0]["QuoteHeaderID"].ToString();
}
}
catch(Exception ex)
{
string s = ex.Message;
DisposeResources(ref oleDbDataAdapter, ref ds, ref connectFill, ref connectCmd, ref cmd);
cmd.Connection.Close();
return 0;
}

View 7 Replies View Related

Error In Function

Oct 17, 2007

This is my function:


=sum(Iif(Fields!FlagPresenca.Value = 1,1,0)=Fields!DataTexto.Value)

I want the sum the values = 1 inside =Fields!DataText.Value, This function return me a error#, Can you help me? Thank you a lot!

View 5 Replies View Related

IsDBNull Function Error!

Jun 28, 2004

What's wrong with this statement?

Dim drTemp As dsContacts.ContactsRow = dsContacts.Contacts.FindByContactID(iContactCode)
.
.
""If Not IsDBNull(drTemp.MobilePhone) Then Me.lblMobilePhone.Text = cstr(drTemp.MobilePhone)""
.
.

When I Execute it , it returns this error message :

Cast from type 'DBNull' to type 'String' is not valid

View 1 Replies View Related

Error Creating CLR Function

Sep 6, 2005

Hi,
When I try to create a CLR function in SQL 2005 (June CTP) I get the following error:
Msg 6505, Level 16, State 1, Procedure Extenso, Line 1Could not find Type 'Extenso' in assembly 'ExtensoNET'.
The assembly registers successfully, with no errors.
I use the following command to create the function:CREATE FUNCTION Extenso (@Valor float)RETURNS VARCHAR(255)AS EXTERNAL NAME ExtensoNET.Extenso.EscreveExtensoGO
The function's code is the following:
using System;using System.Collections.Generic;using System.Text;using Microsoft.SqlServer.Server;using System.Data.SqlClient;
namespace ExtensoNET{ public class Extenso {  [SqlFunction(DataAccess = DataAccessKind.Read)]  public static string EscreveExtenso(double? nValor)  {
  //Valida Argumento  if (nValor==null || nValor <= 0 || nValor > 999999999.99)   return "";
  //Variáveis  int nTamanho;  string cValor, cParte, cFinal;  string[] aGrupo = { "", "", "", "", "" };  string[] aTexto = { "", "", "", "", "" };  .  .  .  }
  return cFinal;
  } }}
Thanks in advance,
Anderson

View 1 Replies View Related

Substring Function Error.....

Jul 29, 2003

select name, datalength(Name),
charindex('_2_', Name),
substring(name, 5, charindex('_2_', Name) - 0)
from msdb.sysjobs.name
name
-------------------- ----------- ----------- -----------
Job_4927_2_7Sun 30 9 4927_2_7S
Job_250144_2_6Sat 34 11 250144_2_6S
Job_30197_2_1Mon 32 10 30197_2_1M

but when I use following - 3)
select name, datalength(Name),
charindex('_2_', Name),
substring(name, 5, charindex('_2_', Name) - 3)
from msdb.sysjobs.name

I get the result I want (last column):
Job_4927_2_7Sun 30 9 4927_2
Job_250144_2_6Sat 34 11 250144_2
Job_30197_2_1Mon 32 10 30197_2

but also with an error:
Server: Msg 536, Level 16, State 3, Line 1
Invalid length parameter passed to the substring function.

thanks
David

View 3 Replies View Related

Getdate() Error In Function

May 2, 2005

I have the below function which errors out telling me "Invalid use of 'getdate' within a function." I can run it as sql but not as a function, is there an issue with using getdate() in a function?

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO




ALTER function fnGetQuantity( @orderid int )
returns int
as
/************************************************** ****************************
** File: fnGetQuantity.sql
** Name: fnGetQuantity
** Desc: Used to calculate the total order quantity for an order
** Quantity is sigfrequency.timesperday * sigdosageamt.descr * orders.duration
**
** Return values: Quantity
**
** Called by:
**
** Parameters: order Id
** Input Output
** ---------- -----------
** @patientid
** Auth: DHoefgen
** Date: 04/30/05
************************************************** *****************************
** Change History
************************************************** *****************************
** Date: Author: Description:
** -------- -------- ------------------------------------------
** 05/02/05 KKowert Changed sql for effdt and added duration and
** times per day logic for zeros.
************************************************** *****************************/
begin
declare @QuantityTotal int


SELECT @QuantityTotal = (o.Duration * f.TimesPerDay * d.Descr)
FROM Orders o INNER JOIN
SIGFrequency f ON o.FreqID = f.FreqID INNER JOIN
SIGDosageAmt d ON o.DosageAmtID = d.DosageAmtID
WHERE (o.OrderID = @orderid) AND (f.Effdt =
(SELECT MAX(f2.Effdt)
FROM SIGFrequency f2
WHERE f2.FreqID = f.FreqID AND f2.Effdt <= getdate())) AND (d.Effdt =
(SELECT MAX(d2.Effdt)
FROM SIGDosageAmt d2
WHERE d2.DosageAmtID = d.DosageAmtID AND d2.Effdt <= getdate()))


return @QuantityTotal

end




GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

View 2 Replies View Related

DATE Function Error

Oct 7, 2014

while using following function I am getting this Error "Msg 195, Level 15, State 10, Line 1 'DATE' is not a recognized built-in function name."

select callid, DATE(segstart) AS calldate
from October_CLI.dbo.raw
Where callid >0
Segstart Column = Data with call date & time
Callid Column = Unique Call Id
October_CLI.dbo.raw = Table
Calldate = Where i want the only date to be capture from segstart column

View 4 Replies View Related

Aggregate Function Error

May 6, 2006

I have made an aggregate function sql (as far as I understand).I need the sum but also the features column. But I can only read one column in the select.Here is the select trying to read two columns:

select oitems.catalogid,oitems.features, sum(oitems.numitems) as SumOfItems from oitems

here is the error:


[Microsoft][ODBC Microsoft Access Driver] You tried to execute a query that does not include the specified expression 'features' as part of an aggregate function.

...anyone?

View 3 Replies View Related

IF..ELSE In Function - Unknown Error

Jul 23, 2005

Hi all,I have the below user-defined function on mssql 2000 and I can't workout why i'm getting the following error:-----Server: Msg 156, Level 15, State 1, ProcedurefnCalculateOutworkerPaymentForBox, Line 15Incorrect syntax near the keyword 'IF'.Server: Msg 170, Level 15, State 1, ProcedurefnCalculateOutworkerPaymentForBox, Line 23Line 23: Incorrect syntax near ')'.----------CREATE FUNCTION fnCalculateOutworkerPaymentForBox(@boxid int)RETURNS moneyASBEGINRETURN (/* if the box is a paperback */IF (SELECT COUNT(BoxID) AS NoOfBoxes FROM OutworkerBoxes WHERE BoxID= @boxid AND BoxCode LIKE '%PAPER%') > 1/* If the books are paperback, charge 15p each and add on 30p for adescription book to make 45p */SELECT ((endref - StartRef) * 0.15) + (NoOfDescriptionBooks * 0.30)FROM OutworkerBoxes WHERE BoxID = @boxidELSE/* If the books are normal, charge 25p each and add 20p on fordescription books to make 45p */SELECT ((endref - StartRef) * 0.25) + (NoOfDescriptionBooks * 0.20)FROM OutworkerBoxes WHERE BoxID = @boxid)END-----Below is the sql for the table it works with:-----CREATE TABLE [OutworkerBoxes] ([BoxID] [int] IDENTITY (1, 1) NOT NULL ,[OutworkerID] [int] NOT NULL ,[ImportedBy] [int] NULL ,[StartRef] [int] NOT NULL ,[endref] [int] NOT NULL ,[DateIssued] [datetime] NOT NULL ,[BoxCode] [nvarchar] (50) COLLATE Latin1_General_CI_AS NOT NULL ,[DealerID] [int] NULL ,[StatusID] [int] NOT NULL ,[IssuedBy] [int] NOT NULL ,[BoxNotes] [nvarchar] (200) COLLATE Latin1_General_CI_AS NULL ,[DateImported] [datetime] NULL ,[NoOfDescriptionBooks] [int] NOT NULL CONSTRAINT[DF_OutworkerBoxes_NoOfDescriptionBooks] DEFAULT (0),CONSTRAINT [PK_OutworkerBoxes] PRIMARY KEY CLUSTERED([BoxID]) WITH FILLFACTOR = 90 ON [PRIMARY]) ON [PRIMARY]GO-----If anyone can advise me i'd be most grateful.Thanx in advanceJames

View 2 Replies View Related

Error In Function Argument

Apr 17, 2007

I have a table with over 11,000 records and I need to do a find and replace using SET and Where conditions. Basically I have one column in the table called RealAudioLink. It contains entries like: wkdy20070416-a.rm and wkdy20070416-b.rm and conv20070416.rm.

I need the select statement to find all wkdy entries and replace those characters with Weekday. I also need it to find all dashes and small a's and b's and replace with null or nothing. Then I need it to insert a capital letter A or B in the
wkdy20070416-a.rm filename so that when it's all said and done that entry would read:

WeekdayA20070416.rm
WeekdayB20070416.rm
Conversation20070416.rm

Here is the code I am working with. It needs help. I'm close but I'm not knowledgeable with using SET or with removing dashes and inserting capital letters all in the same select statement.



Code Snippet

UPDATE T_Programs_TestCopy
(SET RealAudioLink = REPLACE(RealAudioLink, '-a', '')
AND
(SET RealAudioLink = REPLACE(RealAudioLink, 'wkdy', 'WeekdayA')
WHERE (RealAudioLink LIKE 'wkdy%'))

I've never done anything like this before so I would be very appreciative of any assistance with the select statement. I am reading up on it but it would be great to get another perspective from a more experienced sql developer.

Thanks

View 1 Replies View Related

CryptoAPI Function Failed Error

Dec 23, 2004

Hi all

I am facing this error can you help me please it is urgent

CryptoAPI function 'CryptAcquireContext' failed. Error 0x80090006: Invalid Signature.

thank you all

View 1 Replies View Related

Convert Function Query Error

Jul 27, 2005

I am in the middle of creating an editable DatGrid:

Sub AccessoryGrid_EditCommand(source As Object, e As MxDataGridCommandEventArgs)
    AccessoryGrid.EditItemIndex = e.Item.ItemIndex
End Sub

Sub AccessoryGrid_BeforeUpdate(source As Object, e As MxDataGridUpdateEventArgs)
    e.NewValues.Add("@AccessoryID",
AccessoryGrid.DataSource.DataSource.Tables(0).Rows(e.Item.DataSetIndex)
("AccessoryID"))
    e.NewValues.Add("@AccessoryName", CType(e.Item.Cells(1).Controls(0),TextBox).Text)
    e.NewValues.Add("@AccessoryPrice", CType(e.Item.Cells(2).Controls(0),TextBox).Text)
    e.NewValues.Add("@AccessorySold", CType(e.Item.Cells(3).Controls(0),TextBox).Text)
    e.NewValues.Add("@AccessoryDesc", CType(e.Item.Cells(4).Controls(0),TextBox).Text)
    e.NewValues.Add("@AccessoryImage", CType(e.Item.Cells(5).Controls(0),TextBox).Text)
End Sub

For some reason, I get an error message like this:
Server Error in '/' Application.

Disallowed
implicit conversion from data type nvarchar to data type smallmoney,
table 'cardb.dbo.accessories', column 'AccessoryPrice'. Use the CONVERT
function to run this query.



Description: An
unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the
error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException:
Disallowed implicit conversion from data type nvarchar to data type
smallmoney, table 'cardb.dbo.accessories', column 'AccessoryPrice'. Use
the CONVERT function to run this query.

Source Error:





An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.







Stack Trace:




[SqlException: Disallowed implicit conversion from data type nvarchar to data type smallmoney, table 'cardb.dbo.accessories', column 'AccessoryPrice'. Use the CONVERT function to run this query.] System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) +723 System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +194 Microsoft.Saturn.Framework.Web.UI.SqlDataSourceControl.PerformSqlCommand(SqlCommand command) +82 Microsoft.Saturn.Framework.Web.UI.SqlDataSourceControl.Update(String listName, IDictionary selectionFilters, IDictionary newValues) +114 Microsoft.Saturn.Framework.Web.UI.MxDataGrid.OnUpdateCommand(MxDataGridUpdateEventArgs e) +869 Microsoft.Saturn.Framework.Web.UI.MxDataGrid.OnBubbleEvent(Object source, EventArgs e) +546 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +26 Microsoft.Saturn.Framework.Web.UI.MxDataGridItem.OnBubbleEvent(Object source, EventArgs e) +86 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +26 System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +95 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +115 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33 System.Web.UI.Page.ProcessRequestMain() +1277






My main question is, how can I convert my column 'AccessoryPrice' to smallmoney?

I have been trying to get rid of this error by trying to change the
field type within my database with no success, I keep on getting the
same error either way.

I would be very greatful if anybody can  help me.

View 2 Replies View Related

Error: Procedure Or Function Has Too Many Arguments Specified

Dec 9, 2005

Hi,

I've found that I'm not the first one to get the error

"Procedure or function x has too many arguments specified"

while working with Stored Procedures (which is no surprise at all). But
all suggested solutions didn't help, maybe this is because I
misunderstood the whole concept. The situation is: On my page there is
a FormView control including the EditItemTemplate. The database
contains a Stored Procedure called UpdatePersonByID which is working
fine as long as executed in Visual Web Developer. Here's the procedure
code:

ALTER PROCEDURE dbo.UpdatePersonByID
    (
        @LastName varchar(50),
        @FirstName varchar(50),
        @Phone varchar(50),
        @PhonePrivate varchar(50),
        @PhoneMobile varchar(50),
        @Email varchar(50)
    )
AS
    UPDATE
        tblPersons
        SET
            PersonLastName = @LastName,
            PersonFirstName = @FirstName,
            PersonPhone = @Phone,
            PersonPhonePrivate = @PhonePrivate,
            PersonPhoneMobile = @PhoneMobile,
            PersonEmail = @Email
        WHERE
            PersonLastName = @LastName
    RETURN

This is not exactly what it will finally have to do, of course the
WHERE-clause later will contain an ID comparison. But since I tried to
break down my code as much as possible I changed it to what you see
right now. Here's the aspx-source (the red stuff is what I think is
important):

<%@ Page
    Language="VB"
    MasterPageFile="fb10.master"
    AutoEventWireup="false"
    CodeFile="codebehind/staff.aspx.vb"
    Inherits="staff"
    meta:ResourceKey="PageResource"
%>
<%@ MasterType VirtualPath ="~/fb10.master"  %>
<asp:Content
    ID="ContentStaff"
    ContentPlaceHolderID="cphContentMain"
    Runat="Server">
   
    <h3 id="hdStaff" runat="server" meta:resourcekey="Staff" />

    <!-- DataSource srcStaff collects all persons from staff table in database. -->
    <asp:SqlDataSource
        ID="srcStaff"
        runat="server"
        ConflictDetection="CompareAllValues"
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
        SelectCommandType="StoredProcedure"
        SelectCommand="SelectPersonNames"
    />
    <asp:DropDownList
        ID="ddlStaff"
        runat="server"
        DataSourceID="srcStaff"
        DataTextField="CompleteName"
        DataValueField="PersonID"
        AutoPostBack="True">
    </asp:DropDownList>

    <!-- DataSource srcPerson gets person selected in DropDownList "ddlStaff". -->
    <asp:SqlDataSource
        ID="srcPerson"
        runat="server"
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
        ProviderName="System.Data.SqlClient"
        SelectCommand="SelectPersonByID"
        SelectCommandType="StoredProcedure"
        UpdateCommand="UpdatePersonByID"
        UpdateCommandType="StoredProcedure"
        OldValuesParameterFormatString="{0}" >
        <SelectParameters>
            <asp:ControlParameter
                ControlID="ddlStaff"
                DefaultValue="1"
                Name="ID"
                PropertyName="SelectedValue"
                Type="Int32" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="LastName" Type="String" />
            <asp:Parameter Name="FirstName" Type="String" />
            <asp:Parameter Name="Phone" Type="String" />
            <asp:Parameter Name="PhonePrivate" Type="String" />
            <asp:Parameter Name="PhoneMobile" Type="String" />
            <asp:Parameter Name="Email" Type="String" />
        </UpdateParameters>
    </asp:SqlDataSource>

    <!--  DataSource srcBuildings gets all buildings from building table in database. -->
    <asp:SqlDataSource
        ID="srcBuildings"
        runat="server"
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
        ProviderName="System.Data.SqlClient"
        SelectCommand="SelectBuildings"
        SelectCommandType="StoredProcedure">
    </asp:SqlDataSource>
   
    <asp:FormView
        ID="fvStaff"
        runat="server"
        DataSourceID="srcPerson">
        <EditItemTemplate>
            <!--
DataSource srcRooms gets all rooms from room table in database. -->
            <asp:SqlDataSource
                ID="srcRooms"
                runat="server"
   
           
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                ProviderName="System.Data.SqlClient"
                SelectCommand="SelectRoomsByBuildingID"
                SelectCommandType="StoredProcedure">
                <SelectParameters>
                    <asp:ControlParameter
           
           
ControlID="ddlBuildings"
           
           
DefaultValue="1"
           
           
Name="ID"
           
           
PropertyName="SelectedValue"
           
           
Type="Int32"
                    />
                </SelectParameters>
            </asp:SqlDataSource>

            <asp:Label
cssClass="lblIdentifier" ID="lblLastName" runat="server"
meta:resourcekey="LastName" />
           
<asp:TextBox cssClass="staff" ID="LastName" runat="server"
Text='<%# Bind("PersonLastName")
%>'></asp:TextBox><br />

            <asp:Label
cssClass="lblIdentifier" ID="lblFirstName" runat="server"
meta:resourcekey="FirstName" />
           
<asp:TextBox cssClass="staff" ID="FirstName" runat="server"
Text='<%# Bind("PersonFirstName")
%>'></asp:TextBox><br />
           
            <asp:Label
CssClass="lblIdentifier" ID="lblBuilding" runat="server"
meta:resourcekey="Building"></asp:Label>
            <asp:DropDownList
                ID="ddlBuildings"
                cssClass="small"
                runat="server"
                DataSourceID="srcBuildings"
                DataTextField="BuildingAbbreviation"
                DataValueField="BuildingID"
                AutoPostBack="True"
                SelectedValue='<%# Bind("RoomBuildingID") %>'
           
   
OnSelectedIndexChanged="ddlBuildings_SelectedIndexChanged">
            </asp:DropDownList><br />
           
            <asp:Label
cssClass="lblIdentifier" ID="lblRoom" runat="server"
meta:resourcekey="Room" />
            <asp:DropDownList
                ID="ddlRooms"
                cssClass="small"
                runat="server"
                DataSourceID="srcRooms"
                DataTextField="RoomName"
                DataValueField="RoomID"
                AutoPostBack="true"
           
    SelectedValue='<%# Bind("PersonRoomID") %>'>
            </asp:DropDownList><br />

            <asp:Label
cssClass="lblIdentifier" ID="lblPhone" runat="server"
meta:resourcekey="Phone" />
           
<asp:TextBox cssClass="staff" ID="Phone" runat="server" Text='<%#
Bind("PersonPhone") %>'></asp:TextBox><br />
           
            <asp:Label
cssClass="lblIdentifier" ID="lblPhonePrivate" runat="server"
meta:resourcekey="Private" />
           
<asp:TextBox cssClass="staff" ID="PhonePrivate" runat="server"
Text='<%# Bind("PersonPhonePrivate")
%>'></asp:TextBox><br />
           
            <asp:Label
cssClass="lblIdentifier" ID="lblPhoneMobile" runat="server"
meta:resourcekey="Mobile" />
           
<asp:TextBox cssClass="staff" ID="PhoneMobile" runat="server"
Text='<%# Bind("PersonPhoneMobile")
%>'></asp:TextBox><br />

            <asp:Label
cssClass="lblIdentifier" ID="lblEmail" runat="server"
meta:resourcekey="Email" />
           
<asp:TextBox cssClass="staff" ID="Email" runat="server" Text='<%#
Bind("PersonEmail") %>'></asp:TextBox><br />

           
<asp:LinkButton cssClass="lnkButton" ID="UpdateCancelButton"
runat="server" CausesValidation="False" CommandName="Cancel"
Text="<%$resources:translations,
Cancel%>"></asp:LinkButton>
           
<asp:LinkButton cssClass="lnkButton" ID="UpdateButton"
runat="server" CausesValidation="True" CommandName="Update"
Text="<%$resources:translations,
Update%>"></asp:LinkButton>
        </EditItemTemplate>
        <InsertItemTemplate>
            <asp:Label
cssClass="lblIdentifier" ID="lblLastName" runat="server"
meta:resourcekey="LastName" />
           
<asp:TextBox ID="PersonLastNameTextBox"
runat="server"></asp:TextBox><br />
           
            <asp:Label
cssClass="lblIdentifier" ID="lblFirstName" runat="server"
meta:resourcekey="FirstName" />
           
<asp:TextBox ID="PersonFirstNameTextBox"
runat="server"></asp:TextBox><br />
           
            <asp:Label
cssClass="lblIdentifier" ID="lblBuilding" runat="server"
meta:resourcekey="Building" />
           
<asp:TextBox ID="BuildingAbbreviationTextBox"
runat="server"></asp:TextBox><br />
           
            <asp:Label
cssClass="lblIdentifier" ID="lblRoom" runat="server"
meta:resourcekey="Room" />
           
<asp:TextBox ID="RoomNameTextBox"
runat="server"></asp:TextBox><br />
           
           
<asp:LinkButton cssClass="lnkButton" ID="InsertCancelButton"
runat="server" CausesValidation="False" CommandName="Cancel"
Text="<%$resources:translations,
Cancel%>"></asp:LinkButton>
           
<asp:LinkButton cssClass="lnkButton" ID="InsertButton"
runat="server" CausesValidation="True" CommandName="Insert"
Text="<%$resources:translations,
Insert%>"></asp:LinkButton>
        </InsertItemTemplate>
        <ItemTemplate>
            <asp:Label
cssClass="lblIdentifier" ID="lblLastName" runat="server"
meta:resourcekey="LastName" />
            <asp:Label
cssClass="lblValue" ID="PersonLastNameLabel" runat="server"
Text='<%# Bind("PersonLastName") %>'></asp:Label><br
/>

            <asp:Label
cssClass="lblIdentifier" ID="lblFirstName" runat="server"
meta:resourcekey="FirstName" />
            <asp:Label
cssClass="lblValue" ID="PersonFirstNameLabel" runat="server"
Text='<%# Bind("PersonFirstName") %>'></asp:Label><br
/>

            <asp:Label
cssClass="lblIdentifier" ID="lblBuilding" runat="server"
meta:resourcekey="Building" />
            <asp:Label
cssClass="lblValue" ID="BuildingAbbreviationLabel" runat="server"
Text='<%# Bind("BuildingAbbreviation")
%>'></asp:Label><br />

            <asp:Label
cssClass="lblIdentifier" ID="lblRoom" runat="server"
meta:resourcekey="Room" />
            <asp:Label
cssClass="lblValue" ID="RoomLabel" runat="server" Text='<%#
Bind("RoomName") %>'></asp:Label><br />

            <asp:Label
cssClass="lblIdentifier" ID="lblPhone" runat="server"
meta:resourcekey="Phone" />
            <asp:Label
cssClass="lblValue" ID="PhoneLabel" runat="server" Text='<%#
Bind("PersonPhone") %>'></asp:Label><br />

            <asp:Label
cssClass="lblIdentifier" ID="lplPhonePrivate" runat="server"
meta:resourcekey="Private" />
            <asp:Label
cssClass="lblValue" ID="PhonePrivateLabel" runat="server" Text='<%#
Bind("PersonPhonePrivate") %>'></asp:Label><br />

            <asp:Label
cssClass="lblIdentifier" ID="lblPhoneMobile" runat="server"
meta:resourcekey="Mobile" />
            <asp:Label
cssClass="lblValue" ID="PhoneMobileLabel" runat="server" Text='<%#
Bind("PersonPhoneMobile") %>'></asp:Label><br />

            <asp:Label
cssClass="lblIdentifier" ID="lblEmail" runat="server"
meta:resourcekey="Email" />
            <asp:Label
cssClass="lblValue" ID="EmailLabel" runat="server" Text='<%#
Bind("PersonEmail") %>'></asp:Label><br />
           
           
<asp:LinkButton cssClass="lnkButton" ID="DeleteButton"
runat="server" CausesValidation="False" CommandName="Delete"
Text="<%$resources:translations,
Delete%>"></asp:LinkButton>
           
<asp:LinkButton cssClass="lnkButton" ID="EditButton" runat="server"
CausesValidation="False" CommandName="Edit"
Text="<%$resources:translations,
Edit%>"></asp:LinkButton>
        </ItemTemplate>
    </asp:FormView>
</asp:Content>


And then once again a totally different question: Is there a way to
post the highlighted aspx or vb code into this forum and keep the
colors? i think I've seen that in some posts but didn't wanna do it
manually.

Thanks once again for trying to help,

Toob

View 1 Replies View Related

Function Returning Error During Compilation.....

Feb 12, 2004

Hi ,

I am creating a function which is going to return a table. The Code ofr the function is as follows...
===============================
Create function udf_qcard (@cg1 varchar(25)) returns @rec_card table (t_cusip varchar(10),t_data varchar(70))
AS
begin
declare @t1_sys char(10),@t1_all varchar(11)
declare @temp_qcard table (tdata varchar(11) collate SQL_Latin1_General_CP1_CS_AS)
if (substring(@cg1,1,2)='Q$')
set @cg1 = (select substring(@cg1,3,len(@cg1)) where substring(@cg1,1,2)='Q$')
DECLARE c1 SCROLL CURSOR FOR select groups_system, substring(groups_alldata,3,10) from tbl_groups
where groups_system = @cg1 and groups_alldata like 'Q$%' and groups_seq>=1 FOR READ ONLY
insert into @temp_qcard values(@cg1)
OPEN C1
FETCH NEXT FROM c1 INTO @t1_sys,@t1_all
WHILE @@FETCH_STATUS = 0
BEGIN

insert into @temp_qcard values(@t1_all)

declare @t2_sys char(10),@t2_all varchar(10)
DECLARE c2 SCROLL CURSOR FOR select groups_system, substring(groups_alldata,3,10) from tbl_groups
where groups_system = @t1_all and groups_alldata like 'Q$%' and groups_seq>=1 FOR READ ONLY

begin
OPEN C2
FETCH NEXT FROM c2 INTO @t2_sys,@t2_all
WHILE @@FETCH_STATUS = 0
BEGIN
insert into @temp_qcard values(@t2_all)

declare @t3_sys char(10),@t3_all varchar(10)
DECLARE c3 SCROLL CURSOR FOR select groups_system, substring(groups_alldata,3,10) from tbl_groups
where groups_system = @t2_all and groups_alldata like 'Q$%' and groups_seq>=1 FOR READ ONLY

begin

OPEN C3
FETCH NEXT FROM c3 INTO @t3_sys,@t3_all
WHILE @@FETCH_STATUS = 0
BEGIN
insert into @temp_qcard values(@t3_all)
FETCH NEXT FROM c3 INTO @t3_sys,@t3_all
end
end
close c3
deallocate c3
FETCH NEXT FROM c2 INTO @t2_sys,@t2_all
end
end
close c2
DEALLOCATE c2

FETCH NEXT FROM c1 INTO @t1_sys,@t1_all
END

CLOSE c1
DEALLOCATE c1
Insert @rec_card select groups_q+groups_cusip,groups_data from tbl_groups
where groups_system in (select tdata from @temp_qcard) and groups_seq>=1 and groups_alldata not like 'Q$%' order by groups_alldata

RETURN
END
==========================

While compiling this I am getting the Below error ....
==================
Server: Msg 1049, Level 15, State 1, Procedure udf_qcard, Line 10
Mixing old and new syntax to specify cursor options is not allowed.
Server: Msg 1049, Level 15, State 1, Procedure udf_qcard, Line 23
Mixing old and new syntax to specify cursor options is not allowed.
Server: Msg 1049, Level 15, State 1, Procedure udf_qcard, Line 35
Mixing old and new syntax to specify cursor options is not allowed.
=================

Can Anyone please help me how to resolve this issue...

Thanks with Regards.

-Mohit.

View 1 Replies View Related

SQL Server 2012 :: CDC Get All Changes Function Error

Nov 13, 2014

I have setup CDC on 50 tables and then in one SP I’m calling all cdc function like below issue is I'm getting error “an insufficient number of arguments were supplied for the procedure or function cdc.fn_cdc_get_all_changes ... .” as error is not mentioning for which capture instance I'm getting this error so not able to find.

select * from cdc.fn_cdc_get_all_changes_<capture_instance>(@from_lsn, @to_lsn, 'all update old') union all
select * from cdc.fn_cdc_get_all_changes_<capture_instance>(@from_lsn, @to_lsn, 'all update old') union all
select * from cdc.fn_cdc_get_all_changes_<capture_instance>(@from_lsn, @to_lsn, 'all update old') union all
select * from cdc.fn_cdc_get_all_changes_<capture_instance>(@from_lsn, @to_lsn, 'all update old') union all
select * from cdc.fn_cdc_get_all_changes_<capture_instance>(@from_lsn, @to_lsn, 'all update old') union all
select * from cdc.fn_cdc_get_all_changes_<capture_instance>(@from_lsn, @to_lsn, 'all update old') union all
select * from cdc.fn_cdc_get_all_changes_<capture_instance>(@from_lsn, @to_lsn, 'all update old')

How to find which capture instance is failing?

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved