Showing posts with label writing. Show all posts
Showing posts with label writing. Show all posts

Wednesday, March 21, 2012

Problem with a script to create a DB

hi, I am writing from argentina, and the question is beacuse I have problems to create a new DB from a script, in SQL Express Edition
when I execute the query the following erros appears:
Msg 5133, Level 16, State 1, Line 1
Directory lookup for the file "c:\dce05\dce05_ejemplos_estrella1_Data.MDF" failed with the operating system error 2(El sistema no puede hallar el archivo especificado.).
Msg 1802, Level 16, State 1, Line 1
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
Msg 911, Level 16, State 1, Line 2
Could not locate entry in sysdatabases for database 'dce05_ejemplos_estrella1'. No entry found with that name. Make sure that the name is entered correctly.
Msg 2714, Level 16, State 6, Line 3
There is already an object named 'Productos' in the database.

I am thankful to who helps to solve the problem me
See this file....

http://www.moleculardevices.com/technotes_d1/MDC_D1_D50007_TroubleshootDB.pdf

If the method doesnt work ,then

see this troubleshooting method given on MSDN for the error msg 911
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/trblsql/tr_reslsyserr_1_2d4h.asp

and then finally do this
http://msdn2.microsoft.com/en-us/library/aa933271(SQL.80).aspx

have a nice day...tell me wether it worked or not
|||

post the script... and also is this DEC05 directory exists ... if not create it... if exists then check the permission

pse post the script

Madhu

Problem with %....% in the Parameterized Queries

I am using MS SQL 2000.I am writing a simple search statement in the stored procedure which goes like this
Create Procedure.[dbo].[SelectSearch]
(
@.searchtext nvarchar(100)
)
SELECT * FROM TableName WHERE ColumnName LIKE @.searchtext

i want to enter the value in place of @.searchtext as '%strsearch%'
and i'm trying to enter the value of @.searchtext using Parameterized Queries like this

objcmd = new SqlCommand ("SelectSearch", objConn);
objcmd.CommandType = CommandType.StoredProcedure;
objcmd.Parameters.Add("@.searchtext", "'%" + strsearch + "%'");

but its not working out and giving the error message as
Procedure SelectSearch has no parameters and arguments were supplied

Is this the correct way to add the parameters ? Or
How to add' % on both sides of strsearch thro parameterized queries
Thank you very much in advance


You could simply append the %'s to the value.
strsearch = "%" + strsearch + "%";
objcmd = new SqlCommand ("SelectSearch", objConn);
objcmd.CommandType = CommandType.StoredProcedure;
objcmd.Parameters.Add("@.searchtext" );
Also I'd recommend adding the size of the paremeter to avoid problems later on.
|||

Thank you very much mate .

I was struggling to solve this problem atlast i got the answer . Thnx once again

Saturday, February 25, 2012

Problem Using Stored Proc

Hi Folks.. I'm really new to SQL server

I'm writing a stored procedure as:

ALTER PROCEDURE usp_CDE_IssueProcedure1 AS

DELETE FROM tbl_CDE_IssueTable1
INSERT INTO tbl_CDE_IssueTable1 SELECT MONTH(CreatedDate), CorporateStatus, COUNT(IssueID) FROM tbl_IB_Issue WHERE CreatedDate BETWEEN '2004-01-01' AND '2004-12-31' GROUP BY month(CreatedDate), CorporateStatus

Now when I run this stored procedure, the table just does not get affected.
But on the other hand when I run the query alone that is:
INSERT INTO tbl_CDE_IssueTable1 SELECT MONTH(CreatedDate), CorporateStatus, COUNT(IssueID) FROM tbl_IB_Issue WHERE CreatedDate BETWEEN '2004-01-01' AND '2004-12-31' GROUP BY month(CreatedDate), CorporateStatus

The above query runs absolutely fine.. So can anyone pls tell me whats wrong... I have to get this query in the stored procedure..PLsssssssssssss HELP

Thanks,
Shruti Majithia,
Quinnox Consultancy Services.Hi Shruti,

'ALTER PROC' is used to modify the existing stored procedure without changing the permissions and without affecting the dependent PROCs in the database. So the procedure should be already there in the database. You can use the following check:

if exists (select name from sysobjects where type = 'P' and name = 'usp_CDE_IssueProcedure1')
BEGIN
ALTER PROCEDURE usp_CDE_IssueProcedure1 AS
DELETE FROM tbl_CDE_IssueTable1
INSERT INTO tbl_CDE_IssueTable1 SELECT MONTH(CreatedDate), CorporateStatus, COUNT(IssueID) FROM tbl_IB_Issue WHERE CreatedDate BETWEEN '2004-01-01' AND '2004-12-31' GROUP BY month(CreatedDate), CorporateStatus
END
else
BEGIN
CREATE PROCEDURE usp_CDE_IssueProcedure1 AS
DELETE FROM tbl_CDE_IssueTable1
INSERT INTO tbl_CDE_IssueTable1 SELECT MONTH(CreatedDate), CorporateStatus, COUNT(IssueID) FROM tbl_IB_Issue WHERE CreatedDate BETWEEN '2004-01-01' AND '2004-12-31' GROUP BY month(CreatedDate), CorporateStatus
END
go|||I have the exactly same problem i think..
i have made an sp to update a table.
and everything works with no errors.
exept from that nothing happens.
i the SQL Profiler it says:

exec Content_update @.ContentID = 1, @.Content = N'some text'

but nothing happens

thx in advance

Originally posted by shrutimajithia
Hi Folks.. I'm really new to SQL server

I'm writing a stored procedure as:

ALTER PROCEDURE usp_CDE_IssueProcedure1 AS

DELETE FROM tbl_CDE_IssueTable1
INSERT INTO tbl_CDE_IssueTable1 SELECT MONTH(CreatedDate), CorporateStatus, COUNT(IssueID) FROM tbl_IB_Issue WHERE CreatedDate BETWEEN '2004-01-01' AND '2004-12-31' GROUP BY month(CreatedDate), CorporateStatus

Now when I run this stored procedure, the table just does not get affected.
But on the other hand when I run the query alone that is:
INSERT INTO tbl_CDE_IssueTable1 SELECT MONTH(CreatedDate), CorporateStatus, COUNT(IssueID) FROM tbl_IB_Issue WHERE CreatedDate BETWEEN '2004-01-01' AND '2004-12-31' GROUP BY month(CreatedDate), CorporateStatus

The above query runs absolutely fine.. So can anyone pls tell me whats wrong... I have to get this query in the stored procedure..PLsssssssssssss HELP

Thanks,
Shruti Majithia,
Quinnox Consultancy Services.

Problem using SELECT statement on Access Column Name

Im writing a VB program that queries an MS Access db. The column name is CONTACT#. Using the SQL statement...
"SELECT * FROM CLIENT WHERE CONTACT# = '1'"
Produces an error. I cannot change the name of the column name is there anyway around this?Try this:
SELECT * FROM CLIENT WHERE [CONTACT#] = '1'
:eek: