I don't see what's wrong with this command. >> Create View BCPOutBatchWeightTaiwan AS Select * from batchWeight a JOIN Geography b ON a.GeographyPtr = b.GeographyPtr where b.countrycode = 'tw' << I get the following error if I try to create it. >> Server: Msg 4506, Level 16, State 1, Procedure BCPOutBatchWeightTaiwan, Line 2 Column names in each view must be unique. Column name 'GeographyPTR' in view 'BCPOutBatchWeightTaiwan' is specified more than once. <<
But it runs fine if I run only th 'Select' part of the command without 'CREATE' line.
I have the TAMCreate.sql file which contains the script to create all tables in the Database TAMaintenance. Its created and used in the SqlServer 2000. But i have only SqlServer 7. From the script i copy and paste each table and created upto 7 tables without any problem, when i create the 8th table i get the following error the code for the table
CREATE TABLE AA_Branch_Master( Branch_Code varchar(15) CONSTRAINT PK_AA_Branch_Master1 PRIMARY KEY, Branch_Name varchar(50) NOT NULL, Branch_Opened datetime NOT NULL, Branch_Location varchar(50) NOT NULL, Branch_Province varchar(25) NOT NULL, Branch_Incharge varchar(50) NOT NULL, Branch_Remark varchar(150), Branch_Status BIT(1)) go
Error: Server: Msg 2716, Level 16, State 1, Line 1 Column or parameter #8: Cannot specify a column width on data type bit.
In the same way i have get the error or another table, rest of the tables are created successfully.
the code for the table
CREATE TABLE AA_Supplier_Master( Supp_Code varchar(15) CONSTRAINT PK_AA_Supplier_Master1 PRIMARY KEY, Supp_Name varchar(100) NOT NULL, Supp_Address varchar(150) NOT NULL, Supp_Contact_Person varchar(50) NOT NULL, Supp_Paymode varchar(25) NOT NULL, Supp_Tel1 varchar(25), Supp_Tel2 varchar(25), Supp_Fax varchar(25), Supp_Postbox varchar(15), Supp_Postal_Code varchar(15), Supp_City varchar(50) NOT NULL, Supp_Country varchar(50) NOT NULL, Supp_Status BIT(1)) go
Error: Server: Msg 2716, Level 16, State 1, Line 1 Column or parameter #13: Cannot specify a column width on data type bit.
I had just installed SQL 2005 dev on my laptop and got an error message when I tried to create a package using the BI IDE. I received the same error using VS2005 IDE. But the project was created regardless without any packages. When I tried to create a new package in the project, I received the same error again, but with an option to view the error details.
Following is the text of the error details:
TITLE: Microsoft Visual Studio ------------------------------
"Error: 8624, Severity: 16, State: 1 Internal Query Processor Error: The query processor could not produce a query plan. For more information, contact Customer Support Services."
I have traced this to an insert statement that executes as part of a stored procedure.
INSERT INTO ledger (journal__id, account__id,account_recv_info__id,amount)
There is also an auto-increment column called id. There are FK contraints on all of the columns ending in "__id". I have found that if I remove the contraint on account__id the procedure will execute without error. None of the other constraints seem to make a difference. Of course I don't want to remove this key because it is important to the database integrity and should not be causing problems, but apparently it confuses the optimizer.
Also, the strange thing is that I can get the procedure to execute without error when I run it directly through management studio, but I receive the error when executing from .NET code or anything using ODBC (Access).
Hi, i have been able to create a query in asp.net in the sever explorer. I want to create an statement as a new column. In Access i would do it like this (Agg: [Scored]-[Against]) But how do i call a new column Agg in SQL and then tell it to take Against away from Scored?
SELECT Name, TagID, (SELECT COUNT(TagID) AS Expr1 FROM dbo.mw_PagesTagMap WHERE (TagID = tag.TagID)) AS TagWeight FROM dbo.mw_Tags AS tag
This query works exactly how I want it to. I would like to modify this to NOT return any column that has a TagWeight of 0
SELECT Name, TagID, (SELECT COUNT(TagID) AS Expr1 FROM dbo.mw_PagesTagMap WHERE (TagID = tag.TagID)) AS TagWeight FROM dbo.mw_Tags AS tag WHERE (TagWeight <> 0) I thought this would do it but I'm getting an error "invalied column TagWeight". How would I get this to work?
I am working with employee schedules. Each schedule is comprised ofsegments (shift, lunch, break, training, etc.) that have rankings.Each record has the employee id, the date the shift starts, the startand end time of each segment, the duration,the segment type and itsrank. The start and end times of the schedules can overlap, but thesegment that has the higher rank takes precedence.As a simple example, an employee working 8a-5p will have two records.The shift segment from 8a-5p and a lunch segment from 12p-1p. Thelunch ranks higher so, even though the shift goes from 8a-5p, from12p-1p, the lunch takes precedence.What I'm trying to do is build a query that will collapse the segments.So given the example above, I will now have three records: shift8a-12p, lunch 12p-1p, shift 1p-5p.I have been racking my brain but I just can't figure it out.Ultimately, a programmer in my office will display this in a bar chartformat with each segment type having its own color. I'm trying to do asmuch of the work in SQL so he doesn't have to calculate this stuff inthe code.Any help would be appreciated.Thanks.Angela
Hey all, am a bit new to SQL so excuse my ignorance I am wanting to create a query that uses 2 parameters and returns 20 random records that meet the criteria. One of the parameters is stored in a different table to the one im querying, and the other is a selection made by the user on a VB form.. If its any help, my table schema is:
I have a table with the following columns: Rtype, Amount, Refnumber, Color: Here is what the table looks like:
RD 25 1 blue AB 45 2 green AC 25 3 purple AD 34 4 blue AE 25 5 pink
Now lets say I would like to create new transactions for all 'RD' Rtypes, but I would like to change the Amount to lets say, 99 for all of 'RD' types, but keep the same refNumber. For example, I want to create and insert a new transaction for RD, but with the amount 99, so that the row looks like this:
RD 99 1 blue
Where do I put in the query to change the Amount value? I do not wish to use the update function, because I actually want to create a new row. The query I am using, but not working is:
INSERT INTO EMPLOYEES(Rtype, Amount, Refnumber, Color) SELECT Rtype, Amount, Refnumber, Color FROM Employees WHERE Rtype = 'RD'; Reply With Quote
I am trying to create a CLR UDF in SQL 2005 and cosnistently run into the following error. What am I doing wrong?. Please correct me and show me the right way of doing this.
Msg 6551, Level 16, State 2, Procedure EmailSplitter, Line 3
CREATE FUNCTION for "EmailSplitter" failed because T-SQL and CLR types for return value do not match.
Here is what I am trying to achieve. Split a Email field in the database. For that I am trying to return an array using C# and then trying to call the UDF for the C#.
--1).CLR Code. (EmailSpitter.cs)
using System; using System.Collections.Generic; using System.Text;
namespace SQLTools { public class EmailSplitter { public static string[] Parse(string data) { string[] columnData; string[] separators = new string[1]; separators[0] = " ";
I need to create a "simple" sql query but have it formatted and then emailed to individuals. I am trying to convert over from Oracle but I am having a hard time getting the query to be formatted the way I want. Here is the select statement I tried to use with no luck with xp_sendmail:
SELECT ALARM ID, TIMESTAMP as TIME, CLASS, RESOURCE, P, L, F, ALARM_MESSAGE FROM ALARM_LOG WHERE ([TIMESTAMP] < GETDATE() - 1) ORDER BY [TIMESTAMP];
Here what the output should look like with the column headers underlined and then the column data (notice the column heading ALARM MESSAGE is on the next line before any data):
ALARM ID TIME CLASS RESOURCE P L F -------------------- ----------- ----- ---------------- - - - ALARM_MESSAGE ------------------------------------------------------------- B3_TEMP_ALM 02-02@11:21 ALARM BUILDING3_TEMP N G G BUILDING 3 TEMPERATURE ALARM, CALL SECURITY.
B5_TEMP_ALM 02-02@11:22 ALARM BUILDING5_TEMP N G G BUILDING 5 TEMPERATURE ALARM, CALL SECURITY.
How can I run the query and have it formatted and emailed out? What is the best way to accomplish this?
select c.name FROM sys.tables AS t INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID where t.name= 'Hosea_tblDATA_NOTES'and c.is_identity = 0 order by column_id
I was thinking if it is possible to create a table from the results of this query, my table name(in this case 'Hosea_tblDATA_NOTES') will be a parameter, that whatever table name I pass, with the results I get I will be able to create another table, assuming all data types are varchars, but it should be generic.
I want to create a new table with the about of that query, that output has to be my columns.
Im just wondering if it is possible to use a SQL DB to query game servers, Im very new to SQL, an if it is possible please lead me in the right direction on start this.
I have a question about using the query builder, or just straight sql, to create expressions. My first example caused the query builder to generate a query configuration error:
Expression: EIM_REQUISITION_DETAILS.EST_UNIT_COST * EIM_REQUISITION_DETAILS.REQRD_QTY AS COST
Syntax error: Expecting "," or "FROM" after column alias or "*"
Initially I thought I was dead in the water but then I decided to just run it anyway and it worked! I got my cost. OK so fine the query tool doesn't recognize some sql expressions. Because I am trying to make a large flat file I thought I'd concatenate 2 fields to generate a recognizable requisition, which everyone knows is the year followed by a hyphen then the req number:
My old Access query had this: Req: Right([REQ_YR],2) & "-" & [REQ_NO]
and I tried to change it to this: substring (EIM_REQUISITIONS.REQ_YR from 2 for 2) || '-' || EIM_REQUISITIONS.REQ_NO AS REQ
So apparently my older sql book doesn't have the syntax right. Since I plan to do more of this could someone point me to a reliable book or site that could help me with sql syntax?
This has got to be simple... Every time I try to create this sproc I get the following error: Msg 156, Level 15, State 1, Procedure sp_AddTradeItemsToSelections, Line 5 Incorrect syntax near the keyword 'VIEW'. Its driving me nuts because I can't see anything wrong with line 5 where the view is being created. CREATE PROCEDURE [dbo].[sp_XXXXX] @UserdataIDInt, @BuilderIDInt AS CREATE VIEW TradeItem_Append AS SELECT TradeItemID, UserDataID, BuilderID FROM Selections WHERE (UserDataID = @UserdataID) SELECT TradeItem_Append.UserDataID, TradeItems.BuilderID, TradeItems.TradeID, TradeItems.TradeItem, TradeItems.Price, TradeItems.DDLRefNo, TradeItems.TradeItemID, TradeItems.Details, TradeItems.ProductType, TradeItems.Room, TradeItems.Notes FROM TradeItems LEFT OUTER JOIN TradeItem_Append ON TradeItem_Append.TradeItemID = TradeItems.TradeItemID WHERE (TradeItem_Append.TradeItemID IS NULL)AND(TradeItems.BuilderID = @BuilderID) DROP VIEW TradeItem_Append
Hello All im developing web application in VS2005(C#) while Creating SQLDATASource for Gridview im getting Following error cannot get web application service Please help ME Regards Balagangadharan.R
im creating a ecommerce website, and i need to create a database, im using visual studio .net and when i try to create a new database using VS.net i choose "use sql server authentication" and no matter what i type in for the login id, i get the following ado error
"ADO Error : ' Login failed for user "blank". Reason. Not associated with a trusted SQL server connection.'
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
Hi I have a Win2K SP1 server running SQL 7. Whenever I try to create a DTS package, I get a box headed "DTS CoCreateInstance" with "Error in the DLL" as the box text. I have tried removing and re-installing SQL 7 and have also applied SQL SP 1,2 & 3. There are no errors in the event log, just the popup error outlined above.
I am trying to create an assembly on a sql server 2005 machine but it gives me following error:
Msg 33009, Level 16, State 2, Line 2 The database owner SID recorded in the master database differs from the database owner SID recorded in database 'XYZ'. You should correct this situation by resetting the owner of database 'XYZ' using the ALTER AUTHORIZATION statement.
I tried using the alter authorization statement to change the owner. It did not work.
I am able to create same assembly on another test database but can not create it on this database.
i want to create table using another table but i am getting the following error.
Server: Msg 156, Level 15, State 1, Line 2 Incorrect syntax near the keyword 'AS'.
my query is:
CREATE TABLE errorlog AS SELECT * FROM log where 1=0 becos i a trying to copy the structure of the table log to table errorlog.please rectify my problem,please
We upgraded from SQL Server 2000 to 2005 recently. I'm attempting to create a credential for the first time and I keep getting the error shown below. Can anyone tell me what to do to resolve it? Thank You
TITLE: Microsoft SQL Server Management Studio ------------------------------
Create failed for Credential 'schjob'. (Microsoft.SqlServer.Smo)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.3042.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Create+Credential&LinkId=20476
I am trying to create an assembly on a sql server 2005 machine but it gives me following error:
Msg 33009, Level 16, State 2, Line 2 The database owner SID recorded in the master database differs from the database owner SID recorded in database 'XYZ'. You should correct this situation by resetting the owner of database 'XYZ' using the ALTER AUTHORIZATION statement.
I tried using the alter authorization statement to change the owner. It did not work.
The same assembly is created on another test database but can not create it on this database.
I just wondering where can I find the table of my database SuplliersDatabase. I need to know if it is already exists or not? I tried to look around but then still I can't find it.
(1) create view qcostcentre as select * from dbo.costcentre.dtblcostcentre
>ERR: Msg 208, Level 16, State 1, Procedure qcostcentre, Line 4 Invalid object name 'dbo.costcentre.dtblcostcentre'.
(2) create view qcostcentre as select * from costcentre.pcusers.dbo.dtblcostcentre
>ERR: Msg 7202, Level 11, State 2, Procedure qcostcentre, Line 4 Could not find server 'costcentre' in sys.servers. Verify that the correct server name was specified. If necessary, execute the stored procedure sp_addlinkedserver to add the server to sys.servers.
note: pcusers is a user of 2 database (costcentre & datamaster) with dbo_datareader owned & role schema .
When ever i tried to creat a diagram for the database i have i got this error:
Database diagram support objects cannot be installed because this database does not have a valid owner. To continue, first use the Files page of the Database Properties dialog box or the ALTER AUTHORIZATION statement to set the database owner to a valid login, then add the database diagram support objects.
the version of the database i am working in was backed up from another machine
I have a client who is getting an error when they try to create a report subscription. The error is as follows:
An unexpected error occurred: A subscription delivery error has occurred. ---> A subscription delivery error has occurred. ---> One of the extension parameters is not valid for the following reason: The account you are using does not have administrator priviledges. A subscription cannot be created for [email address].
The thing I find strange is that the client was able to create a shared schedule with no problems, so I don't see how they don't have administrator privileges. The shared schedules and subscriptions are created programmatically through a web application if that is of any importance.
I encountered something strange, deploying the following assemblies
CREATE ASSEMBLY [Sentry]
AUTHORIZATION [dbo]
FROM 'c:clrSentry.dll'
WITH PERMISSION_SET = EXTERNAL_ACCESS;
GO
CREATE ASSEMBLY [Sentry.XmlSerializers]
AUTHORIZATION [dbo]
FROM 'C:clrSentry.XmlSerializers.dll'
WITH PERMISSION_SET = SAFE;
GO
Sentry.XmlSerializers errored out with: Msg 6218, Level 16, State 2, Line 2 CREATE ASSEMBLY for assembly 'Sentry.XmlSerializers' failed because assembly 'Sentry.XmlSerializers' failed verification. Check if the referenced assemblies are up-to-date and trusted (for external_access or unsafe) to execute in the database. CLR Verifier error messages if any will follow this message [ : Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializerContract::CanSerialize][mdToken=0x600006e][offset 0x00000001][token 0x01000019]System.TypeLoadException: Could not load type 'Sentry.SentryDataService.SentryDataService' from assembly 'Sentry, Version=1.0.2764.18017, Culture=neutral, PublicKeyToken=null'. Type load failed.
The interesting thing is that when I deploy this locally on my machine, there are no problems whatsoever. Using sp_configure the servers appear to be set up the same way. The database also has trustworthy set on for both.
Hi all, when I create publication with New Publication Wizard. I get the following errors. Did someone meet this before? Can you help me? Thanks!
===================================
SQL Server could not create publication 'JK'. (New Publication Wizard)
===================================
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
------------------------------ Program Location:
at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType) at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String sqlCommand) at Microsoft.SqlServer.Replication.ReplicationObject.ExecCommand(String commandIn) at Microsoft.SqlServer.Replication.ReplicationObject.CommonCreate() at Microsoft.SqlServer.Replication.Publication.Create() at Microsoft.SqlServer.Management.UI.CreatePublicationWizard.CreatePublicationThreadMethod()
===================================
Cannot promote the transaction to a distributed transaction because there is an active save point in this transaction. Changed database context to 'Test'. (.Net SqlClient Data Provider)
------------------------------ For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.2047&EvtSrc=MSSQLServer&EvtID=3933&LinkId=20476
------------------------------ Server Name: nxstudio-davidsql2k5_dc Error Number: 3933 Severity: 16 State: 1 Procedure: sp_addmergepublication Line Number: 1034
------------------------------ Program Location:
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType)