String Constants Must End With A Double Quote.

Apr 2, 2007

i got this error when i was trying to deploy the report... in the preview mode report is working good....



D:
eport1.rdl The expression for the query €˜dataset€™ contains an error: [BC30648] String constants must end with a double quote.



can any one gimme the solution




View 11 Replies


ADVERTISEMENT

String Constants Must End With A Double Quote.

May 5, 2008

Hi There,

I can't figure out what is causing this error: can you please have a look at my code and let em know what is wrong or rework it for me:

="SELECT ARIBC.cntbtch, ARIBC.btchdesc, ARIBC.AUDTUSER, ARIBC.AUDTDATE, ARIBC.AUDTTI, GLPSOFTMAP.PSPRODUCT, GLPSOFTMAP.PSDEPT, GLPSOFTMAP.PSACCOUNT, GLPSOFTMAP.ACCTID, ARIBH.CODECURN, ARIBH.INVCDESC, CONVERT(varchar,ARIBH.FISCYR + ARIBH.FISCPER) as PERIOD, CONVERT(varchar,ARIBH.IDCUST) AS ACCOUNT, ARCUS.NAMECUST as ARNAME, CASE TEXTTRX WHEN 1 THEN 'INV' WHEN 2 THEN 'DM' WHEN 3 THEN 'CM' END AS CLASS, CONVERT(varchar,ARIBH.IDINVC) AS TRX_NUMBER, (CASE TEXTTRX WHEN 3 THEN ROUND((ARIBD.AMTEXTN*-1),2) ELSE ROUND((ARIBD.AMTEXTN),2) END) AS ""AMOUNT FROM ARIBC"" INNER JOIN ARIBH ON ARIBC.CNTBTCH = ARIBH.CNTBTCH INNER JOIN ARCUS ON ARIBH.IDCUST = ARCUS.IDCUST INNER JOIN ARIBD ON ARIBH.CNTBTCH = ARIBD.CNTBTCH AND ARIBH.CNTITEM = ARIBD.CNTITEM INNER JOIN GLAMF ON ARIBD.IDACCTREV = GLAMF.ACCTFMTTD INNER JOIN GLPSOFTMAP ON ARIBD.IDACCTREV = GLPSOFTMAP.ACCTID WHERE ARIBC.BTCHSTTS=3 AND ERRENTRY <= 0 AND BTCHDESC NOT LIKE '%54-8003%' AND ARIBH.IDINVC in ('" &Replace(Parameters!invoicenum.Value,",","','")"

Thanks,
RC

View 1 Replies View Related

SQL Server 2008 :: Remove Double Quote In String Fields

Feb 23, 2015

I have a SQL select syntax as below

0 AS SalaryMin,
2088 AS SalaryMax,
2088 AS BillableHours,
'Month' AS SalaryPaidCode,
0 AS SalaryBreakdownHourly,
0 AS SalaryBreakdownDaily,

[Code] ...

While outputting to CSV.file

I got :0,2088,2088,"Month",0,0,0,0,0,0,0,"N/A","N/A","G","N/A","Exempt","Other",1

How can I remove all double quotes in the string fields? so that O can get the result as below while the output
0,2088,2088,Month,0,0,0,0,0,0,0,N/A,N/A,G,N/A,Exempt,Other,1

View 7 Replies View Related

T-SQL (SS2K8) :: Find All Instances Of String That Contain Certain Letters - Escape Double Quote

Sep 14, 2015

I am trying to find all instances of a string that contain the letters FSC. While I am able to find most of them, I am unable to find the ones wrapped in double quotes.

Query example:

Select *
from myTable
Where item like '%FSC%'

This works great with the exception of when FSC is surrounded by double quotes.

ex: MySentencecontains"FSC"

I have tried Replace with no luck.

View 3 Replies View Related

Double Quote In Database Record

Dec 14, 2005

In my asp.net page when I run a query against the database the datagrid get populated with only the records that starts with the first letter for example A good day. But none of the records that starts like this "A fine day" or "A nice day" displays in the datagrid. I tried to replace the Double Quote but it still returns only the records without " quotes. My query looks like this:
Dim queryString As String = "SELECT [Articles].[AN], [Articles].[Department], [Articles].[ArticleHeading], [Articles].[AccessLevel], [Articles].[Status] FROM [Articles] WHERE (([Articles].[AccessLevel] <> 'SysAdmin') AND ([Articles].[Status] = 'Enable') AND (REPLACE([Articles].[ArticleHeading], 'chr(34)', '')) like @ArticleHeading) ORDER BY [Articles].[ArticleHeading]"

View 6 Replies View Related

Double Quote In Beginning Of Record

Dec 14, 2005

Some of my records starts with a double quote, when I do a search for all records starting with A I can get all except the ones that start "A fine day ...

View 4 Replies View Related

Searching For Double Quote In Sql Server 2005

Jun 11, 2008

Hi ,
I'm using sql server 2005. In my 'Books' table some of the 'subject' column contains data's with single and double quote. example: Quantu"m phys'ics
i'm passing the subject as parameter and it have to display results if the corresponding subject name is in the table. Here is my code... i'm using dynamic query...
 alter procedure getbooks
@sub varchar(200)
as
begin
declare @sqlq nvarchar(2000)
set @sqlq='select subject from books where subjectname like '''+@sub+'%'''
exec sp_executesql @sqlq
end
 How can i search for words like this Quantu"m phys'ics in the above query? Any one who knows how to do this please send me the code..
 

View 9 Replies View Related

Export A View With Double Quote Delimiter

Aug 14, 2006

i am running sql server 2000 on windows 2000. i have a need to export a view and delimit the columns with double quotes as it has imbedded commas in the columns, how do i do this??

View 1 Replies View Related

SQL 2012 :: SSIS Double Quote Text Qualifiers

Dec 12, 2014

We have an issue with importing a CSV file into SQL where using a double quote " text qualifier is failing. The data is correct but it fails on a particular line, complaining about the qualifier even though the qualifier is in place and previous lines have imported fine.

View 3 Replies View Related

Using Password Ending In Unmatched Double Quote Mark With OleDbConnection

Mar 14, 2008


Issue



I need to write VS2005 C# code using SQL OLE DB to access SQL Server 2005. I have no choice in that matter. I can create a database user with a password like COMPANY", which is a string of uppercase characters ending in an unmatched double-quote mark.

Using Microsoft SQL Server Server Management Studio I login using Windows Authentication, create an account with the password, COMPANY", check the "Enforce password policy", click "OK", and then exit.


Setup


I launch Microsoft SQL Server Server Management Studio again, select "SQL Server Authentication", type in the account name and the COMPANY" password, click the Connect button, and I'm in.

Problem


Now, I need to connect programmatically and run a stored procedure. The password is stored in clear text in hte Registry€”not my choice, it's a legacy application, and changing that is not an option open to me. (We have probably all seen company safes where the combination is scribbled on the wall in case you forget it!)

Here is the code I use to run the sproc:


DBCONNINFOLib.DBConnectionInfoClass DBConnInfo1 = new DBCONNINFOLib.DBConnectionInfoClass();
String strConnString = DBConnInfo1.GetConnectionString( "" );
OleDbConnection con1 = new OleDbConnection( strConnString );
OleDbCommand cmd1 = con1.CreateCommand();
cmd1.CommandType = CommandType.StoredProcedure;
String sCmdText = "sp_SomeStoredProcedure";
cmd1.CommandText = sCmdText;

If I set the connection string in the registry to COMPANY", I get an error like this:


Server Error in '/' Application.


Response is not available in this context.
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.Web.HttpException: Response is not available in this context.

Source Error:





Line 60: catch (System.Exception e)
Line 61: {
Line 62: Response.Write(e.Message.ToString());
Line 63: }
Line 64:
Source File: C:sourceProductNameDataCenterAdm&ReportsWebPagesProductNameWebCommonCodeCommon.cs Line: 62

Stack Trace:





[HttpException (0x80004005): Response is not available in this context.]
System.Web.UI.Page.get_Response() +2077605
SiteIQWeb.CommonCode.Common..ctor() in C:ProductNameDataCenterAdm&ReportsWebPagesProductNameWebCommonCodeCommon.cs:62
SiteIQWeb.MasterPage..ctor() in C:ProductNameDataCenterAdm&ReportsWebPagesProductNameWebMasterPage.master.cs:21
ASP.masterpage_master..ctor() in c:WINDOWSMicrosoft.NETFrameworkv2.0.50727Temporary ASP.NET Files
oot255b545c8a400c7App_Web_hfj8popy.0.cs:0
__ASP.FastObjectFactory_app_web_hfj8popy.Create_ASP_masterpage_master() in c:WINDOWSMicrosoft.NETFrameworkv2.0.50727Temporary ASP.NET Files
oot255b545c8a400c7App_Web_hfj8popy.3.cs:0
System.Web.Compilation.BuildResultCompiledType.CreateInstance() +49
System.Web.UI.MasterPage.CreateMaster(TemplateControl owner, HttpContext context, VirtualPath masterPageFile, IDictionary contentTemplateCollection) +250
System.Web.UI.Page.get_Master() +48
System.Web.UI.Page.ApplyMasterPage() +18
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +685




Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433


The closes to success I have been able to come is to set the password to "COMPANYNAME""" or 'COMPANYNAME"', which results in a System.Data.OleDb.OleDbConection Exception with a HResult of 0x80040e4d, and the message Login failed for user 'username'.


Questions


Can the password be formatted differently in the registry, or somehow processed after retrieving it, so that SQL Server 2005 will accept it?

Is this a bug in .NET Framework or SQL OleDb?

Is this simply a case of "Is it hurts, don't do it"?

Thanks in advance. As with all postings, my job, promotion, product success, company future, or some combination thereof is on the line.

View 2 Replies View Related

SSIS Undouble - Inline Double Quote And Column Delimeter Problem

Apr 24, 2007

We have problems with SSIS flat file adapter.

We try to import file which contains next sort of data:

"1";"ABC";5
"2";"A""BC""";5
"3";"A""B;C""";5

The resulting table must be:
f1 f2 f3
1 ABC 5
2 A"BC" 5
3 A"B;C" 5

How can we get this result?

p.s.
We tried to use "SQL Server SSIS Sample Component: UnDouble" but the result was unsuccesfull.

View 11 Replies View Related

Form Field Returns Name With Double Quotes Instead Of Single Quote During Update Process.

Oct 3, 2007

I've a weird problem in my application. In of the pages, while trying to update the text box "Name", when I enter Linda's test, it gets saved as Linda''s test. I'm not sure if this is a problem due to SQL server. When I look at the stored procedure, I don't anything different. Also, when I update the table directly in SQL Server, the result is displayed in single quote. But if I update the field thro' the application, the returned name is with double quotes instead of single quote.  Has any of you faced problems like this? What am I missing? What do I need to do to get the name saved the way I entered (with single quotes) instead of double quotes?

View 1 Replies View Related

Reporting Services :: SSRS 2012 - CSV Rendering / Turn Off Double Quote Qualifier

Sep 29, 2015

I have scoured the Microsoft forums and the internet to find out how I can generate the output of a CSV report that has double quotes around each value and is comma separated as follows:

"Abcd","123456","Efghi","789012","JKLMN"

If I try to concatenate double quotes around the values in the stored procedure or in the RDL, two double quotes appear around each value as follows. 

""Abcd"",""123456"",""Efghi"",""789012"",""JKLMN""

I understand that this is because the default qualifier is double quote.  What I see is that every time a double quote appears in a value (along with commas and line breaks), the qualifier will activate.  Is there any way to turn this off for double quotes? 

If I try to enter:  <Qualifier>false</Qualifier>, the word "false" appears as the qualifier instead.

The only way I have found that produces a result similar to what I need ("Abcd","123456","Efghi","789012","JKLMN") is if I add a line break - chr(10) in the RDL in each field. However, this won't work for me because I can't have line breaks in each field in the output. 

Note that in SSRS 2005, I was able to produce the report output as I state above by setting the field delimiter and qualifier as follows:

<FieldDelimiter>@?!?@</FieldDelimiter>
<Qualifier>?#^?</Qualifier>

This essentially turned the field delimiter and qualifier off, as the values entered would never appear in the data.  I then could add double quotes and commas in the RDL.  This used to work in the old version but does not anymore.

View 4 Replies View Related

Single Quote In A String

Mar 9, 2006

Hi,

i am trying to add a single quote to a string. This is a must because i am making a full select statement in which i need the single quote to compare values. Obviously this breaks my string invalidating my query.

ej:

SELECT avg(tabla.ip_trend_value) as valor, FLOOR(Cast(tabla.ip_trend_time AS FLOAT)) as tiempo
FROM TESTLAB5.dbo.CE02_L21_916AI31_43 tabla, TESTLAB5.dbo.CE02_L21_916XI31_4 t2
WHERE t2.ip_trend_value = 'Alimentacion Digestores' and t2.ip_trend_time = tabla.ip_trend_time
group by FLOOR(Cast(tabla.ip_trend_time AS FLOAT))

and this will become something like this.

SELECT @TableName = 'TESTLAB5.dbo.'+@TableName
SELECT @SQL = 'SELECT avg(tabla.ip_trend_value), FLOOR(Cast(tabla.ip_trend_time AS FLOAT)) FROM '
SELECT @SQL = @SQL + @TableName
SELECT @SQL = @SQL + ' tabla, TESTLAB5.dbo.CE02_L21_916XI31_4 t2'
SELECT @SQL = @SQL + ' WHERE t2.ip_trend_value = '@NombreVar'and t2.ip_trend_time = tabla.ip_trend_time'
SELECT @SQL = @SQL + ' group by FLOOR(Cast(ip_trend_time AS FLOAT))'

the @NombreVar is the equivalence of 'Alimentacion Digestores'.

is there something i can add or change to make it work ?

View 2 Replies View Related

Single Quote In NVARCHAR String?

Sep 20, 2005

How do I get a single quote (') in a NVARCHAR string in MS SQL Server?e.g. SELECT @strsql = "SELECT * FROM tblTest WHERE Field1 Like 'blah''Obviously this is invalid as the single quote before "blah" would end thevarchar string.How do I get round this?

View 8 Replies View Related

My Application Throws Error When I Have Single ( ' ) Quote In My String (SQL Database)

Aug 29, 2007

my asp.net application communicate with SQL database, but when I have single quote ( ' ) in my string then it throws error. and it does not insert that string in database.  How can I solve this problem . or give me some suggestions  on this issue.
 thank you
maxmax

View 3 Replies View Related

String Variable With Embedded Quotes Getting Changed To Slash/quote

Jul 9, 2007

I have a Foreach loop that dynamically builds a query that gets submitted to a Progress 9.1d database. The "SELECT" portion of the query is static - the WHERE clause is built dynamically each pass through the for each loop. The vast majority of the columns have a dash ("-") in their names, so the query passed to progress has to have double quotes surrounding the column names. Not a big deal you would think. If I am retrieving 3 columns, my string would look like "SELECT ""manager-name"", ''"employee-name"", ""date-of-hire"" FROM PUB.EmployeeTable" - with the columns requiring quoted identifiers escaped with double quotes. My script task adds some additional info to the WHERE clause based on other conditions. Once my script task has built the query string, it assigns that string value to my Dts.Variables("SqlString") variable.



I can put a MsgBox() call in the Script task to display my query once it has been built (displaying Dts.Variables("SqlString").Value) - and it looks fine. Using the above example, it would simply be: SELECT "manager-name", "employee-name", "date-of-hire" FROM PUB.EmployeeTable.



So - My foreach loop is set up so that the query command is pulled from my Dts.Variables("SqlString") variable. It fails anytime my query has a column that requires quotes around it. I was confused, since I could take the exact query string displayed by my test MsgBox() and validate it's syntax against our Progress database (and even run it) and it worked fine.



So - I then inserted a breakpoint to break on PreExecute for the DataReader task (next task after Scrip task) to view the value of the Dts.Variables("SqlString") variable just before it gets assigned to the DataReader's Sql Command property. That's when I noticed that the value of the Dts.Variables("SqlString") in the Watch window actually showed that the "double" double quotes I had entered in the SELECT clause (to escape to one double quote) were being replaced with " (slash quote). SO - in the Watch window, my Dts.Variables("SqlString").Value reads as follows:

SELECT "manager-name", "employee-name","date-of-hire" FROM PUB.EmployeeTable.



Obviously, that query is not going to fly via SQL-92/ODBC connection to our Progress database. I've tried everything I can think of - even trying to replace "" with "" in the Foreach expression editor where the Sql Command of the data reader gets assigned. I'm at a total loss. Why would SSIS plug in what looks like C# character escaping syntax when all the expressions are supposed to be VB.NET? I've already successfully run several packages that query our Progress databases that do NOT use the double quotes in the SELECT clause and they work fine. Does anyone have any ideas??

View 3 Replies View Related

Truncation Error Arrising From Quote Escaped Quotes In Quote Encapsulated Strings

Feb 15, 2006

Hi All,

I'm having trouble importing a CSV file into SQL using SSIS. The trouble seems to stem from truncation and from quote encapsulated fields.

Firstly it's worth noting that some of the data within the quotes contains the separator. E.g.

12,"some text, and a comma",34

Thankfully SSIS seems to cope with that by specifying " as the Text Qualifier. My next problem was that the SSIS Import and Export Wizard gave an error: "failed because truncation occurred". But I fixed this by specifying the OutputColumnWidth for the NCHAR and NVARCHAR type columns to be the width from the table definition.

But now I have another problem with the length of fields. Consider the following where the center column is NCHAR (22)

101,"some text, and a comma",303
102,"some ""quoted text"" bye",303

The first row has the correct width (once the encapsulating quotes are stripped out), but the second row does not, because it seems that when I exported the table the export wizard escaped the quote characters within encapsulated strings using quote characters. So I am back to getting the "truncation occurred" error. How can I get around this within SSIS?

Cheers,

Tim.

View 1 Replies View Related

String To Double Calculation

Mar 29, 2006

i get an error when executing ,
Select sum(ToDouble(Jan_Hours)) from employeepayments
where Employer_Number = '2346' and [Year] = '2005'

the Jan_Hours is an varchar type of column.

how to get sum(Jan_Hours) + sum(Feb_hours) +
i also need sum (sum(Jan_Hours) + sum(Feb_hours))

View 17 Replies View Related

Cast From String 'OPEN' To Type 'Double' Is Not Valid.

Aug 12, 2007

Hi.. Please help me resolve this error "Cast from string 'OPEN' to type 'Double' is not valid.". Error here If CallStatus = 10 Then ....Code:Public Sub UpdateCallStatus()        Dim CALLID, RequestorID, CommentsFromITD, MessageFromITD, MessageToITD, CallStatus, strSQL As String        CALLID = Request.QueryString("CallID")        RequestorID = Session("USER_ID")        CommentsFromITD = lblcomments.Text        MessageFromITD = lblmessage.Text        MessageToITD = txt_desc.Text        CallStatus = Trim(Request.Form(ddl_callstatus.UniqueID))
        Dim ObjCmd As SqlCommand        Dim ObjDR As SqlDataReader
        Try            If CallStatus = 10 Then                strSQL = "UPDATE CALLS  SET STATUS_ID=" & CallStatus & " WHERE CALL_ID=  " & CALLID & ""                ObjCmd = New SqlCommand(strSQL, ObjConn)                ObjConn.Open()                ObjDR = ObjCmd.ExecuteScalar()                gbVariables.insertuserevents(CALLID, RequestorID, "Call Closed")                Response.Redirect("UserCallClosed.aspx")                ObjConn.Close()            Else                strSQL = "UPDATE CALLS  SET STATUS_ID=" & CallStatus & " WHERE CALL_ID=  " & CALLID & ""                ObjCmd = New SqlCommand(strSQL, ObjConn)                ObjConn.Open()                ObjDR = ObjCmd.ExecuteScalar()                ObjConn.Close()
                strSQL = "SELECT STATUS_LABEL  FROM STATUS WHERE STATUS_ID = " & CallStatus & ""                ObjCmd = New SqlCommand(strSQL, ObjConn)                ObjConn.Open()                ObjDR = ObjCmd.ExecuteScalar()                ObjConn.Close()
                gbVariables.insertuserevents(CALLID, RequestorID, CallStatus)                CallStatus = ""            End If        Catch ex As Exception            lblmsg.Text = ex.Message.ToString        End Try    End SubThanks...

View 1 Replies View Related

Reporting Services :: Double Space In A String Value SSRS?

May 14, 2015

we have a value in a column with double space between characters like" abcd  efgh", when I do the preview of the report I see the value as it is with double space; but when I deploy the report on to the reporting server, I just see only single space between the characters. whys is it eliminating one space when it is deployed on the reporting server? how can I get the same value with 2 spaces?

View 2 Replies View Related

Searching A String With Asian Characters (double Byte)

Jun 14, 2007

My problem is that i can't search a field that contains Asian characters (Korean in this case).



The table user_Access_tab have 2 keys:

access_id nVarchar(50)

user_id nVarchar(50)



The sql query below is sent through a oledbcommand to a sql server 2005 database.



"select access_id, access_right from user_Access_tab where user_id ='HQ001kimjo012007-05-07 ì˜¤ì „ 11:50:323401'"



It doesn't show any hits even thogh i know there is a number of matching records.



The question doesn't generate an answer in SQL server manager studio eigher.



If i change the datatype on user_id to Varchar(50) the id is presented (in the database) as:

HQ001kimjo012007-05-07 ?? 11:50:323401



Then the question works, but why doesn't it work with nVarChar(50)?



Regards Martin Jonsson

View 1 Replies View Related

SQL Server 2012 :: Query Get Data In Double Codes In String

Feb 9, 2014

I have data like this

"entitlementwrapper" : [ {
"Type" : "Factory Warranty",
"Date_Type" : "Ship date",
"Status" : "Active",
"Start_Date" : "2012-12-21",
"End_Date" : "2014-01-19",
"Days_Left" : "116",
"Term" : "13",
"Description" : "Wty: HP HW Replacement Support",
"IsTrusted" : "Y",
"Transaction_ID" : "4644780453"
}

I want to get only data in double codes in using sql query.

View 9 Replies View Related

SQL Server 2008 :: DOUBLE Precision For Calculations / Convert To Double?

May 19, 2011

I am performing a series of calculations where accuracy is very important, so have a quick question about single vs double precision variables in SQL 2008.

I'm assuming that there is an easy way to cast a variable that is currently stored as a FLOAT as a DOUBLE prior to these calculations for reduced rounding errors, but I can't seem to find it.

I've tried CAST and CONVERT, but get errors when I try to convert to DOUBLE.

For example...

SELECT CAST(1.0/7.0 AS FLOAT)
SELECT CONVERT(FLOAT, 1.0/7.0)

both give the same 6 decimal place approximation, and the 6 decimals make me think this is single precision.

But I get errors if I try to change the word FLOAT to DOUBLE in either one of those commands...

SELECT CAST(1.0/7.0 AS DOUBLE)

gives "Incorrect syntax near )"

SELECT CONVERT(DOUBLE, 1.0/7.0)

gives "Incorrect syntax near ,"

View 2 Replies View Related

DB Engine :: Double Row Added From A Source Table That Did Not Have Double Record

Aug 28, 2014

Every night we connect to a remote server using Linked Server and copy details from that database to a loading table, then load it into the 'real' table in our own environment. The remove database we load it from has indexes/primary keys that match the 'real', however the 'loading' table itself does not have any indexes or primary keys, both are SQL Server 2005 machines.

In the loading table we first of all truncate it then do a select insert statement from the remote server, then we then truncate the 'real' table and load iit from the 'loading' table.

The issue is when we attempted to load it into our 'real' table from our loading table there was a duplicate row, and our process failed with a Primary Key violation.

I checked the source with does have the same primary key's in, it did not contain a duplicate row and I checked the loading table and that did contain a duplicate row.

My question this is in what circumstances this could happen ?

View 5 Replies View Related

Using Constants In DTS

Mar 22, 2004

I am really new to DTS but I have had moderate success creating packages to move and tranform data in one DB to a new DB. The problem I am having is that I can not figure out how to use a constant in my transformation.

I am moving data from an old DB to a new DB. Currently all of my users in the old DB will have the same user role in the new DB. So I basically want to move all of my user ids to a lookup table and then give them all the same role id. Seems like it should be easy, but no luck here.

Does anyone have some advice?

thanks

View 1 Replies View Related

How Do I Use Constants In Stored Procedures?

Jul 20, 2005

I have several instances of "magic number" variables (tinyints). In myprogram, I have assigned an enumeration to make the meaning clear, such as:enum Condition {Green = 0,Yellow,Red}In my database, one of the tables contains a "Condition" field (tinyint),which stores the number 0, 1 or 2. However, in my Stored Procedures I amhaving to use magic numbers as follows:SELECT * From Nodes Where Condition = 1(to select all nodes with yellow condition)Obviously, meaning is obfuscated here. I would rather use constants but nothave to re-define them in every stored procedure I use.I there any way to do this?

View 1 Replies View Related

Using Defined Constants In Stored Procedures

Apr 21, 2008

I would like to create a file named macro_def.m that contains the following:

define(_HELP,1000)
define(_INSERT,2000)
define(_UPDATE,3000)
define(_DELETE,4000)

define(_retcode,`eval($1)')

Then in any stored procedure that I have I would like to do something like:

CREATE PROCEDURE [dbp].[sp_AddNew]
INCLUDE "macro_def.m"
BEGIN
insert into tablex (name,number) values ("text",_retcode(_INSERT))
END
GO

Questions:
What is the syntax in the SP to inlude a file like macro_def.m ?
Where do I save the macro_def.m file ?
Do I need to include a path in the INCLUDE statement ?

View 5 Replies View Related

Passing Constants In Data Flows

Jan 13, 2006

Hi

Does anyone know what would be the best technique to use for passing constants into data flows shapes?

For example if I had a lookup that required a static value to be passed into it as part of a concatenated key etc...

Cheers

Al

View 1 Replies View Related

The Name 'HeaderID' Is Not Permitted In This Context. Only Constants, Expressions, Or

Oct 5, 2007

I'm pulling data from one database in which the headerID is the primary key which automatically increases by one on each insert. Modifying all of the other fields from one data type to another and then inserting them into another database after the convertion is done. I keep getting this error.

The name 'HeaderID' is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted.

INSERT INTO [DatabaseName].[dbo].[InvoiceHeaderConverted]
([HeaderID], [InvoiceNumber], [StoreNumber], [DeliveryDate], [DueDate],
[TotalInvoice], [TotalTax], [ManifestNumber])
VALUES(HeaderID = @HeaderID, InvoiceNumber = @InvoiceNumber, StoreNumber = @StoreNumber,
DeliveryDate = @DeliveryDate, DueDate = @DueDate, TotalInvoice = @TotalInvoice,
TotalTax = @TotalTax, ManifestNumber = @ManifestNumber)

Can anyone point me in the right direction on this one. The headerid isn't autogenerated in the second database but is still the primary key.

View 4 Replies View Related

Error : Only Constants, Constant Expressions, Or Variables Allowed Here.

Jun 9, 2004

hi all,
when I try to do the following insert for the table test

create table test (outputs character(10), chk integer)

insert into test values('a',((select count(*) from test where outputs='a')+1))

I am getting the error
The name 'outputs' is illegal in this context. Only constants, constant expressions, or variables allowed here. Column names are illegal.

when i tried the same in DB2 it's working fine. is there anyerror in my syntax or this kind of function not allowed in SQL Server.

regards
Melb

View 1 Replies View Related

Setup And Upgrade :: Clarification On Non-integer Constants Are Not Allowed In ORDER BY Clause In 90

May 15, 2015

We're upgrading our SQL Server database from 2005 to 2012.I ran the Upgrade Advisory report and got this issue "Non-integer constants are not allowed in the ORDER BY clause in 90" because of the script below

SELECT
gp.BRAND+' <> '+gp.CATEGORY AS 'full name',
gp.PRODCODE,
gp.CATEGORY
FROM dbo.GFK_PRODUCT gp
ORDER BY
'full name'

I tried running the same query in our test SQL Server 2012 and it ran successfully. Now I'm confuse if i still need to change it.I google the issue a bit and came across this link and mentioned this.

1.) Non-integer constants are ... constants that are not integer number.

Example: 'string1' represents
a string constant
0x01 represents
a varbinary constant
{ts
'2015-02-26 06:00:00'} represents a datetime constant

1.23 represents
a numeric constants

2) So single quotes are used to define a string constants / character string constants but SQL Server allows also to use single quotation marks use also as column identifier
delimiter:
SELECT ... expression AS 'Column1'
FROM ...

In this context is clear that 'Column1' is a column identifier but when used in ORDER BY : ORDER BY 'Column1' it generates confusion because SQL Server doesn't knows if it represents a string literal (character string constant) or it represents a column identifier / column name."Do I still need to change the existing code even though it's working fine in 2012? If yes, it is because of best practice reason or it will total get deprecated/not working in the future version?

View 4 Replies View Related

Valid Expressions Are Constants, Constant Expressions, And (in Some Contexts) Variables. Column Names Are Not Permitted.

Dec 11, 2007

I want to have this query insert a bunch of XML but i get this error...


Msg 128, Level 15, State 1, Procedure InsertTimeCard, Line 117

The name "ExpenseRptID" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.

Msg 128, Level 15, State 1, Procedure InsertTimeCard, Line 151

The name "DateWorked" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.

What am i doing wrong...Can anyone help me out!! Thanks!!

p.s I know this query looks crazy...


Code Block

IF EXISTS (SELECT NAME FROM sysobjects WHERE NAME = 'InsertTimeCard' AND type = 'P' AND uid=(Select uid from sysusers where name=current_user))
BEGIN
DROP PROCEDURE InsertTimeCard
END
go
/*********************************************************************************************************
** PROC NAME : InsertTimeCardHoursWorked
**
** AUTHOR : Demetrius Powers
**
** TODO/ISSUES
** ------------------------------------------------------------------------------------
**
**
** MODIFICATIONS
** ------------------------------------------------------------------------------------
** Name Date Comment
** ------------------------------------------------------------------------------------
** Powers 12/11/2007 -Initial Creation
*********************************************************************************************************/
CREATE PROCEDURE InsertTimeCard
@DateCreated DateTime,
@EmployeeID int,
@DateEntered DateTime,
@SerializedXML text,
@Result int output
as
declare @NewTimeCardID int
select @NewTimeCardID = max(TimeCardID) from OPS_TimeCards
-- proc settings
SET NOCOUNT ON

-- local variables
DECLARE @intDoc int
DECLARE @bolOpen bit
SET @bolOpen = 0
--Prepare the XML document to be loaded
EXEC sp_xml_preparedocument @intDoc OUTPUT, @SerializedXML
-- check for error
IF @@ERROR <> 0
GOTO ErrorHandler
--The document was prepared so set the boolean indicator so we know to close it if an error occurs.
SET @bolOpen = 1


--Create temp variable to store values inthe XML document
DECLARE @tempXMLTimeCardExpense TABLE
(
TimeCardExpenseID int not null identity(1,1),
TimeCardID int,
ExpenseRptID int,
ExpenseDate datetime,
ProjectID int,
ExpenseDescription nvarchar(510),
ExpenseAmount money,
ExpenseCodeID int,
AttachedRct bit,
SubmittoExpRep bit
)
DECLARE @tempXMLTimeCardWorked TABLE
(
TimeCardDetailID int not null identity(1,1),
TimeCardID int,
DateWorked DateTime,
ProjectID int,
WorkDescription nvarchar(510),
BillableHours float,
BillingRate money,
WorkCodeID int,
Location nvarchar(50)
)
-- begin trans
BEGIN TRANSACTION
insert OPS_TimeCards(NewTimeCardID, DateCreated, EmployeeID, DateEntered, Paid)
values (@NewTimeCardID, @DateCreated, @EmployeeID, @DateEntered, 0)
-- check for error
IF @@ERROR <> 0
GOTO ErrorHandler


--Now use @intDoc with XPATH style queries on the XML
INSERT @tempXMLTimeCardExpense (TimeCardID, ExpenseRptID, ExpenseDate, ProjectID, ExpenseDescription, ExpenseAmount, ExpenseCodeID, AttachedRct, SubmittoExpRep)
SELECT @NewTimeCardID, ExpenseRptID, ExpenseDate, ProjectID, ExpenseDescription, ExpenseAmount, ExpenseCodeID, AttachedRct, SubmittoExpRep
FROM OPENXML(@intDoc, '/ArrayOfTimeCardExpense/TimeCardExpense', 2)
WITH ( ExpenseRptID int 'ExpenseRptID',
ExpenseDate datetime 'ExpenseDate',
ProjectID int 'ProjectID',
ExpenseDescription nvarchar(510) 'ExpenseDescription',
ExpenseAmount money 'ExpenseAmount',
ExpenseCodeID int 'ExpenseCodeID',
AttachedRct bit 'AttachedRct',
SubmittoExpRep bit 'SubmittoExpRep')
-- check for error
IF @@ERROR <> 0
GOTO ErrorHandler

-- remove XML doc from memory
EXEC sp_xml_removedocument @intDoc
SET @bolOpen = 0


INSERT OPS_TimeCardExpenses(TimeCardID, ExpenseRptID, ExpenseDate, ProjectID, ExpenseDescription, ExpenseAmount, ExpenseCodeID, AttachedRct, SubmittoExpRep)
Values(@NewTimeCardID, ExpenseRptID, ExpenseDate, ProjectID, ExpenseDescription, ExpenseAmount, ExpenseCodeID, AttachedRct, SubmittoExpRep)
select @NewTimeCardID, ExpenseRptID, ExpenseDate, ProjectID, ExpenseDescription, ExpenseAmount, ExpenseCodeID, AttachedRct, SubmittoExpRep
from @tempXMLTimeCardExpense
-- check for error
IF @@ERROR <> 0
GOTO ErrorHandler

-- For time worked...
INSERT @tempXMLTimeCardWorked(TimeCardID, DateWorked, ProjectID, WorkDescription, BillableHours, BillingRate, WorkCodeID, Location)
SELECT @NewTimeCardID, DateWorked, ProjectID, WorkDescription, BilliableHours, BillingRate, WorkCodeID, Location
FROM OPENXML(@intDoc, '/ArrayOfTimeCardWorked/TimeCardWorked', 2)
WITH ( DateWorked DateTime 'DateWorked',
ProjectID datetime 'ProjectID',
WorkDescription nvarchar(max) 'WorkDescription',
BilliableHours float 'BilliableHours',
BillingRate money 'BillingRate',
WorkCodeID int 'WorkCodeID',
Location nvarchar(50)'Location')
-- check for error
IF @@ERROR <> 0
GOTO ErrorHandler

-- remove XML doc from memory
EXEC sp_xml_removedocument @intDoc
SET @bolOpen = 0


INSERT OPS_TimeCardHours(TimeCardID, DateWorked, ProjectID, WorkDescription, BillableHours, BillingRate, WorkCodeID, Location)
Values(@NewTimeCardID,DateWorked, ProjectID, WorkDescription, BillableHours, BillingRate, WorkCodeID, Location)
select @NewTimeCardID ,DateWorked, ProjectID, WorkDescription, BillableHours, BillingRate, WorkCodeID, Location
from @tempXMLTimeCardWorked


-- commit transaction, and exit
COMMIT TRANSACTION
set @Result = @NewTimeCardID
RETURN 0

-- Error Handler
ErrorHandler:
-- see if transaction is open
IF @@TRANCOUNT > 0
BEGIN
-- rollback tran
ROLLBACK TRANSACTION
END
-- set failure values
SET @Result = -1
RETURN -1

go

View 1 Replies View Related







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