Stored Procedure Text Is Not Storing In Database
May 14, 2008
hi
in my front end i have one text area where user can input his sql statements. for samller data its working. the data type of coulmn is Text in sql server 2005. but problem is when i try to store this data its showing error.i meant not storing data at all. if i cut some of line from this then in this case it stores the data .what should i do to overcome this problem
thanx a lot.
DECLARE @sTemp VARCHAR(10)
DECLARE @nMemberID INT
DECLARE @nPartnerID INT
DECLARE @nDocumentTypeNo INT
DECLARE @nDocumentFormat INT
DECLARE @sEmailAddress VARCHAR(200)
SET @sTemp = '{*MEMBERID*}'
IF UPPER(@sTemp) = 'NULL'
SET @nMemberID = NULL
ELSE
SET @nMemberID = CAST(@sTemp AS INT)
SET @sTemp = '{*PARTNERID*}'
IF UPPER(@sTemp) = 'NULL'
SET @nPartnerID = NULL
ELSE
SET @nPartnerID = CAST(@sTemp AS INT)
SET @sTemp = '{*DOCUMENTTYPENO*}'
IF UPPER(@sTemp) = 'NULL'
SET @nDocumentTypeNo = NULL
ELSE
SET @nDocumentTypeNo = CAST(@sTemp AS INT)
SET @sTemp = '{*DOCUMENTFORMAT*}'
IF UPPER(@sTemp) = 'NULL'
SET @nDocumentFormat = NULL
ELSE
SET @nDocumentFormat = CAST(@sTemp AS INT)
SET @sEmailAddress = '{*EMAILADDRESS*}'
IF EXISTS(SELECT *
FROM ProtocolSettings
WHERE ((@nMemberID IS NULL AND MemberID IS NULL) OR MemberID = @nMemberID)
AND ((@nPartnerID IS NULL AND PartnerID IS NULL) OR PartnerID = @nPartnerID)
AND ((@nDocumentTypeNo IS NULL AND DocumentTypeNo IS NULL) OR DocumentTypeNo = @nDocumentTypeNo)
AND ((@nDocumentFormat IS NULL AND DocumentFormatNo IS NULL) OR DocumentFormatNo = @nDocumentFormat)
AND ProtocolSettingNo = 307)
BEGIN
UPDATE ProtocolSettings
SET SettingValue = @sEmailAddress
WHERE ((@nMemberID IS NULL AND MemberID IS NULL) OR MemberID = @nMemberID)
AND ((@nPartnerID IS NULL AND PartnerID IS NULL) OR PartnerID = @nPartnerID)
AND ((@nDocumentTypeNo IS NULL AND DocumentTypeNo IS NULL) OR DocumentTypeNo = @nDocumentTypeNo)
AND ((@nDocumentFormat IS NULL AND DocumentFormatNo IS NULL) OR DocumentFormatNo = @nDocumentFormat)
AND ProtocolSettingNo = 307
END
ELSE
BEGIN
INSERT INTO ProtocolSettings (ProtocolSettingNo, MemberID, PartnerID, DocumentTypeNo, DocumentFormatNo, SettingValue)
VALUES(307, @nMemberID, @nPartnerID, @nDocumentTypeNo, @nDocumentFormat, @sEmailAddress)
END
View 4 Replies
ADVERTISEMENT
Jan 27, 2005
Hey folks,
Just a quick question to ask what is the best field to store the data held in a rich text box/control. Just want to make sure that i get it right first time you know. Not sure about the amount of characters that needs held but its going to be quite a lot as this field shall contain most of my pages content.
Appreciate any help
Thanks
Turklad
View 3 Replies
View Related
Jan 24, 2008
Hi All,
I have to execute one of the stored procedure within another stored procedure.
And have to store it into some table variable...
How to do that.pls give me the syntax...
Thanks and reagards
A
View 1 Replies
View Related
Jul 5, 2007
Hi
i m new in sqlserver databases
i need to know how to "store output of data from stored procedure in a text file "
suppose i have a stored procedure which has to cuculate some out put from some tables and in the end i want that all out put in comma delimited text file.
my databse name is check1
i need help please
thanks in advance
take care
bye
View 1 Replies
View Related
Mar 28, 2008
All,
I'm trying to store the results of my store procedure in a temp table. when I try it, I got the error saying...
"Insert exec cannot be nested"
I suspsect this is because I have a Insert Exec statement inside my stored procedure...
Is there any way to come over this issue ?
syntax of my code...
create table #Temp1 (ID int)
insert into #Temp1
EXEC SP1
when I try to run the above code I get the error "Insert exec cannot be nested"
SP syntax :
Create Procedure SP1
as
Begin
create table #Temp2
statements.....
Insert into #temp2
exec SP<Name>
staments.. cont...
END
View 5 Replies
View Related
Jul 20, 2005
In order to minimize the number of connection strings I have to use toaccess different databases on the same Sql Server, I was consideringstoring all stored procedures in just one database. I want to do thisbecause connection pooling in my application - ASP.NET is based onthis connection string. So if I need to access 6 different databaseson one sql server & set 6 different connection strings, I end upcreating 6 different connection pools.Other than it might create more management work for the DBA, are thereany performance implications with implementing this scheme? Do storedprocedures run any slower if they access tables that are stored indifferent databases within the same server?Any comments/suggestions are appreciated.TIA,Minh Tran
View 4 Replies
View Related
Jul 20, 2005
Is it possible to execute a stored procedure in one database, which thenitself executes a stored procedure from another database? We have decide tosplit our data into a tree structure (DB1) and data blobs (DB2) (we areusing MSDE and we have a 2gb limit with each DB so we've done it this wayfor that reason). I would like to, say, execute a stored procedure in DB1,passing in the data blob and other details, DB1 will create a tree node inDB1 and then add the blob record to DB2. DB1 will wrap in a transaction ofcourse, as will DB2 when it adds the blob. Is this possible?
View 1 Replies
View Related
Dec 29, 2006
Hello there,I just want to ask if storing data in dbase is much better than storing it in the file system? Because for one, i am currenlty developing my thesis which uploads a blob.doc file to a web server (currently i'm using the localhost of ASP.NET) then retrieves it from the local hostAlso i want to know if im right at this, the localhost of ASP.NET is the same as the one of a natural web server on the net? Because i'm just thinking of uploading and downloading the files from a web server. Although our thesis defense didn't require us to really upload it on the net, we were advised to use a localhost on our PC's. I'll be just using my local server Is it ok to just use a web server for storing files than a database?
View 6 Replies
View Related
May 6, 2002
How can I determine the length of a text value from a column defined as text? Len works really well with char and varchar but not text. How can I do it?
Also, need same for nchar, nvarchar, and image.
Thanks,
Chris
View 3 Replies
View Related
Jan 16, 2008
Hi,I've got some XML which exists as a text variable in a temp table in SQL Server 2000.I need to pass this XML into sp_xml_preparedocument so I can rebuild a table out of it. But I can't figure out the syntax.If I try doing this:declare @idoc intexec sp_xml_preparedocument @idoc output, (select XmlResult from #cache)I get an error, with or without the brackets round the select statement.The temp table is created using an SP, but I can't call that directly either. This:declare @idoc intexec sp_xml_preparedocument @idoc output, exec Search$GetCache @searchIDAlso throws an error.I can't put it into a
local variable because they can't be of type text. I can't pass it into
the SP somewhere as it's being generated on the fly.How can I get my xml into sp_xml_preparedocument?Cheers,Matt
View 3 Replies
View Related
Apr 17, 2007
Hi,
I have a problem with importing text into a database.
I have an application in .net where I fill a textbox with a certain text. When I press a button the text shall be separated and inserted into a database. The big question here is: how do I seperate the text so I get it into different colums in the database?
I know there is someting called InString, should I use this or is there an other way? I was thinking I could use a stored procedure.
Thanks in advance.
View 3 Replies
View Related
Jun 5, 2007
How to find a text within a SP,by issuing a sql query or command?
Thanks in advance.
View 2 Replies
View Related
Jan 16, 2008
Hi,
I've got some XML which exists as a text variable in a temp table in SQL Server 2000.
I need to pass this XML into sp_xml_preparedocument so I can rebuild a table out of it. But I can't figure out the syntax.
If I try doing this:
declare @idoc int
exec sp_xml_preparedocument @idoc output, (select XmlResult from #cache)
I get an error, with or without the brackets round the select statement.
The temp table is created using an SP, but I can't call that directly either. This:
declare @idoc int
exec sp_xml_preparedocument @idoc output, exec Search$GetCache @searchID
Also throws an error.
I can't put it into a local variable because they can't be of type text. I can't pass it into the SP somewhere as it's being generated on the fly.
How can I get my xml into sp_xml_preparedocument?
Cheers,
Matt
View 4 Replies
View Related
Mar 28, 2007
I have a stored procedure that calls a msdb stored procedure internally. I granted the login execute rights on the outer sproc but it still vomits when it tries to execute the inner. Says I don't have the privileges, which makes sense.
How can I grant permissions to a login to execute msdb.dbo.sp_update_schedule()? Or is there a way I can impersonate the sysadmin user for the call by using Execute As sysadmin some how?
Thanks in advance
View 9 Replies
View Related
Jun 7, 2007
I am trying to inject dynamically generated text into a Sql2000 stored procedure. What am I doing wrong?A code behind routine generates the following string value based on a visitor entering 'sail boats' in TextBox1. The routine splits the entry and creates the below string.Companies.L_Keywords LIKE '%sail%' AND Companies.L_Keywords LIKE '%boats%'
I am trying to place this string result in the WHERE statement of a Sql2000 Stored Procedure using parameter @VisitorKeywords.
PROCEDURE dbo.KWsearchAS SELECT DISTINCT Companies.L_Name, Companies.L_ID, Companies.L_EnabledWHERE ( @visitorKeywords ) AND (Companies.L_Enabled = 1)ORDER BY Companies.L_Name
I am wanting the resulting WHERE portion to be:
WHERE ( Companies.L_Keywords LIKE '%sail%' AND Companies.L_Keywords LIKE '%boats%' ) AND (Companies.L_Enabled = 1)
Thank you
View 10 Replies
View Related
Aug 4, 2004
Hi guys,
I need to be able to send a text file with data seperated by tabs to a stored procedure that populates my table.
I am new to SQL and SPROCs that I am not sure how to even start. If you guys have any ideas I would really like to hear them or maybe any on-line docs and examples.
Thanks in advance!
View 2 Replies
View Related
Apr 13, 2001
Hi List
I have stored procedure which need 4 input variables. I want to send the stored procedure output to Table or text file. Is there any way I can do it let me know. Here is the stored procedure.
Exec TestProcedure 'USD',@test1 output, @test2 output, @test3 output
Thanks in advance
Wang...
View 2 Replies
View Related
Sep 7, 1999
Is there a way to use BCP or something else within a stored procedure to extract data from a select statement out to a text file?
View 4 Replies
View Related
Aug 7, 1998
Hi!!!
Is it possible to create a stored procedure which will create a text file (containing information from some tables) and send it via e-mail to a list of user.
I know that I will have to configure the SQL Mail.
If it is possible, can someone give me sample code.
Thanks you.
View 1 Replies
View Related
Mar 19, 2001
I want to sort a stored procedure based on a variable passed to it... what is the easiest way to do this? Here's an example of what I want to do:
sp_select_thing 10, 'thing_name', 'asc'
It would run the query then somehow evaluate parameters 2 and 3 to be placed in the ORDER BY clause. I'm not sure if they should be quoted as strings or not, I don't have an idea how to pass a "reference to a variable" as a parameter to a stored procedure... or even if such a thing is possible
Thanks!
View 1 Replies
View Related
Aug 23, 2004
Hai..
I have data in text files ( not in csv format but in a properitary format).
My requirment is to read the text files and parse it into corresponding data and then store it into the MSSQL Server Database.
Is there any way to do this by using Stored Procedure or extended stored prodcedure in SQL Server. Or is there any other way to do this in
SQL Server. My database is there in SQL 2000.
Any help will be appreciated..
with regards
Sudar
View 14 Replies
View Related
Oct 19, 2011
I have a sp which saves the necessary information regarding the status of action(whether success or failure, rows affected etc) to a log table say( StatusLog )After this, I was sending a database mail with information taken from the log table via sp_send_dbmail. Now I would like to write the status information to a 'txt' file instead of sending via mail.How can I write to a text file from a stored procedure in ms sql server 2005?
View 6 Replies
View Related
Sep 26, 2013
Want to write from a table variable to a text file from a stored procedure.Read about xp_cmdshell bcp etc. but worried because it's supposed to be a security problem and needs to be from a permanent database.Also am getting error "The EXECUTE permission was denied on the object 'xp_cmdshell'..."
1. Is xp_cmdshell a bad idea to use even if I get permissions ?
2. Can a "permanent" table be used in a stored procedure starting out fresh each time with 0 rows rather than use a table variable ?
View 2 Replies
View Related
Jan 27, 2006
Hi
I'm trying to create a stored procedure using the northwind db which will do the following:
SELECT ProductID, ProductName, QuantityPerUnit, UnitPrice, UnitsInStock
FROM Products
However, where UnitsInStocks = 0 I would like the words "Sorry, out of stock" to appear. I will then call this from an ASP page.
Can anyone help please?
Cheers
Woolly
View 7 Replies
View Related
Sep 9, 2005
Greetings,I have a sp that dumps text into a textfile but I am having troublecreating the textfile.EXEC master.dbo.xp_cmdShell '\servernamed$The Filesubfilename.dat'The directory "The File" has a space in it. I've tried putting thecarat ^ before the space, and putting double quotes...but I keepgetting this error'\servernamed$The' is not recognized as an internal or externalcommand, operable program or batch file.If I do EXEC master.dbo.xp_cmdShell '"\servernamed$TheFilesubfilename.dat"' I get the same thing.If I do EXEC master.dbo.xp_cmdShell '""\servernamed$TheFilesubfilename.dat""' I get'"\servernamed$The Filesubfilename.dat"'is not recognized as an internal or external command, operable programor batch file.Does anybody see what I am doing wrong?
View 3 Replies
View Related
Apr 4, 2007
In SQL 2005 (we use Enterprise 64-bit SP2), the users cannot see thetext of the stored procedures, functions, etc.This is a production database, so I cannot give them rights to modifythem, but they need to be able to see what the procs are doing.I didn't have this problem in 2000 - how can I adjust the privilegesto allow them to view the contents of the Programmability objects?thanks for any insight!!Tracy
View 2 Replies
View Related
Mar 29, 2006
hi
Writing to text file from table/view is done using osql,bcp etc. How do we write output of stored procedure into text file??
Thank you
View 4 Replies
View Related
May 16, 2008
Hello,
I was wondering if you could help resolve a simple question - namely how to input a type text value as a parameter to a stored procedure, which expects that type of input.
Text type variables are not allowed and casting to varchar in this case will not work as the input will be far longer than 8000 characters.
Thanks!
View 3 Replies
View Related
May 28, 2006
Hi,
I'm new to ASP.NET 2.0. I have a sqldatasource and a formview controls on a web page and inside the formview control I have two textboxes. When I click the UPDATE button in the formview, I'd like to be able to retrieve the values of the textboxes inside the formview control and pass these values to a 'Update' SQL stored procedure defined in the Sqldatasource.
Does anyone know how I can do this? Hope my question is clear.
Thanks in advance.
hakl
View 1 Replies
View Related
Nov 4, 1999
I am stuck! and need help!
I have a problem I can't seem to find the solution with this aweful limitations on VARCHAR fields of 255.
Within a stored procedure called Store_Check, I need to dynamically build a string (@string) using VARCHAR(255) since the text datatype can't be used in a stored procedure.
So,this string is built according to whether the Store ID is NOT NULL. So if the StoreID is not null, I start building this string 'Exec Update_Store_Address @StoreID1, @address2'. There are 20 StoreID's passed into Store_Check. IF all 20 StoreID's are not NULL, the executed String greatly exceeds 255 because the string winds up looking like this
'Exec Update_Store_Address @StoreID1, @address1 Exec Update_Store_Address @StoreID2, @address2 Exec Update_Store_Address @StoreID3, @address3 Exec Update_Store_Address @StoreID4, @address4 Exec Update_Store_Address @StoreID5, @address5 Exec Update_Store_Address @StoreID6, @address6 etc. etc.'
I am not executing this string within the StoredCheck procedure. It needs to be passed as ONE string to a VB program and it gets executed by the VB program. Even if I create 4 local variables and concatenate them, it stops at the 255th character.
Also, a local varialbe of type TEXT cannot be declared within stored procedure.
What can I do? I am stuck!
Angel
View 1 Replies
View Related
Jul 21, 2015
I have made this defination for a stored procedure:
PROCEDURE EP_Conterbalances
@Start_Date_For_Totals_Date DATETIME,
@EmpFilterAddDuty VARCHAR(500),
@CounterBalanceType_id INT,
@dateFrom DATETIME,
[Code] .....
The value of @EmpFilterAddDuty could be:
'SELECT E.EmployeeID FROM dbo.EmployeeGroupMapToEmployee E, dbo.Per_Budget B WHERE E.EmployeeID = B.PER_PERSONAL_ID AND B.PEB_Budget_id = 243 AND E.EmployeeGroupID IN (SELECT H.Id FROM dbo.EmployeeGroup H WHERE H.InstitutionsId = 22) GROUP BY E.EmployeeID '
If i Replace @EmpFilterAddDuty with this in a QUERY, it gives me the expected result, but if i try to execute the stored procedure.:
DECLARE@return_value int
EXEC@return_value = [dbo].[EP_Conterbalances]
@Start_Date_For_Totals_Date = N'20120831',
@EmpFilterAddDuty = 'SELECT E.EmployeeID FROM dbo.EmployeeGroupMapToEmployee E, dbo.Per_Budget B
[Code] .....
I get this error code:
Conversion failed when converting the varchar value 'SELECT E.EmployeeID FROM dbo.EmployeeGroupMapToEmployee E, dbo.Per_Budget B WHERE E.EmployeeID = B.PER_PERSONAL_ID AND B.PEB_Budget_id = 243 AND E.EmployeeGroupID IN (SELECT H.Id FROM dbo.EmployeeGroup H WHERE H.InstitutionsId = 22) GROUP BY E.EmployeeID ' to data type int.
I really do not understand why SQL 2012 tries to convert the value to an int, and I want to know how to pass the text string.
View 4 Replies
View Related
Sep 7, 2007
I need to create a stored procedure that allows a full text search with multiple filters. The FTS is a three variable proximity (x near y near z) drawing from three textboxes which works fine in my VB application:
WHERE CONTAINS(SectionText, ' """ & SearchTerm1 & """ NEAR """ & SearchTerm2 & """ NEAR """ & SearchTerm3 & """ ')
The filters consist of 4 comboboxes and 2 textboxes. I am trying to use the dynamic SQL approach found here:
http://www.sommarskog.se/dyn-search.html
The dynamic SQL in the stored procedure that I have created based on this model works fine for filtering, but I have not been able to get my FTS query integrated with it. I have tried various ways of declaring the SearchTerms as parameters, etc. but no luck.
Any help in getting this to work (or advice for using a different approach that is more appropriate) would be greatly appreciated.
Code Snippet
CREATE PROCEDURE ECR_Advanced_Search2
@fulldocno nvarchar(10) = NULL,
@doctype nvarchar(10) = NULL,
@year nvarchar(6) = NULL,
@sex nvarchar(7) = NULL,
@category nvarchar(10) = NULL,
@agenum smallint = NULL,
@agecat nvarchar(10) = NULL,
@debug bit = 0 AS
DECLARE @sql nvarchar(4000),
@paramlist nvarchar(4000),
@searchterm1 nvarchar(100),
@searchterm2 nvarchar(100),
@searchterm3 nvarchar(100)
SELECT @sql =
'SELECT FullDocuments.FullDocNo, FullDocuments.DocType, Details.Year
FROM FullDocuments
INNER JOIN Details ON FullDocuments.FullDocNo = Details.FullDocNo
WHERE 1 = 1 AND CONTAINS(SectionText, @searchterm1 NEAR @searchterm2 NEAR @searchterm3)'
IF @fulldocno IS NOT NULL
SELECT @sql = @sql + ' AND FullDocuments.fulldocno = @xfulldocno'
IF @DocType IS NOT NULL
SELECT @sql = @sql + ' AND FullDocuments.DocType = @xDocType'
IF @year IS NOT NULL
SELECT @sql = @sql + ' AND Details.year = @xyear'
IF @sex IS NOT NULL
SELECT @sql = @sql + ' AND Details.sex = @xsex'
IF @category IS NOT NULL
SELECT @sql = @sql + ' AND Details.category = @xcategory'
IF @agenum IS NOT NULL
SELECT @sql = @sql + ' AND Details.agenum = @xagenum'
SELECT @sql = @sql + ' ORDER BY FullDocuments.FullDocumentID'
IF @debug = 1
PRINT @sql
SELECT @paramlist =
'@xfulldocno nvarchar(10),
@xdoctype nvarchar(10),
@xyear smallint,
@xsex nvarchar(7),
@xcategory nvarchar(10),
@xagenum smallint,
@xagecat nvarchar(10)'
EXEC sp_executesql @sql, @paramlist, @doctype,
@fulldocno, @year, @sex,
@category, @agenum, @agecat
View 7 Replies
View Related
Apr 16, 2015
We have a legacy database that have hundreds of stored procedures.
The previous programmar uses a string like servername.databasename.dbo.tablename in the stored procedures.
We now have migrated the database to a new server. The old server is either needed to be replaced by the new server name, or remove it.
I don't know why he used servername as part of the fully qualified name, we don't use linked servers. So I think better removing the servername in all the stored procedures.
I know I can do a generate script, and replace the text and then use alter procedure to recreate all the stored procedures. But since hundreds of them, is there a programmatically way to replace them?
View 2 Replies
View Related