Could someone please tell WHY it is not allowed to use the following construction in a stored procedure!?
AS IF @taxparent = 0 THEN SET @taxparent = NULL IF @museum = 0 THEN SET @museum = NULL IF @collection = 0 THEN SET @collection = NULL SELECT ID, SpecimenNr, ScientificName, Locality, Taxon FROM QueryView
I get the following error messsages:
Msg 156, Level 15, State 1, Procedure DynamicQuery, Line 9Incorrect syntax near the keyword 'THEN'.Msg 156, Level 15, State 1, Procedure DynamicQuery, Line 10Incorrect syntax near the keyword 'THEN'.Msg 156, Level 15, State 1, Procedure DynamicQuery, Line 11Incorrect syntax near the keyword 'THEN'
Hi, I was trying to run an insert statement which has subquery, But it is returning the error like this.. Subqueries are not allowed in this context. Only scalar expressions are allowed. -------------- Is there a way to reparse the insert statement without have to assign the subquery to a temp value and insert it? thanks.. Here is my SQL.. insert into admincriteria values (nextID,(select id from nodetable where description like 'Example - Quality Analytics'),8071,2,'Failures by Customer',2,0,0)
Can anyone please give me the equivalent tsql for sql server 2000 for the following two queries which works fine in sql server 2005
1 -- Full Table Structure
select t.object_id, t.name as 'tablename', c.name as 'columnname', y.name as 'typename', case y.namewhen 'varchar' then convert(varchar, c.max_length)when 'decimal' then convert(varchar, c.precision) + ', ' + convert(varchar, c.scale)else ''end attrib,y.*from sys.tables t, sys.columns c, sys.types ywhere t.object_id = c.object_idand t.name not in ('sysdiagrams')and c.system_type_id = y.system_type_idand c.system_type_id = y.user_type_idorder by t.name, c.column_id
2 -- PK and Index select t.name as 'tablename', i.name as 'indexname', c.name as 'columnname' , i.is_unique, i.is_primary_key, ic.is_descending_keyfrom sys.indexes i, sys.tables t, sys.index_columns ic, sys.columns cwhere t.object_id = i.object_idand t.object_id = ic.object_idand t.object_id = c.object_idand i.index_id = ic.index_idand c.column_id = ic.column_idand t.name not in ('sysdiagrams')order by t.name, i.index_id, ic.index_column_id
This sql is extracting some sort of the information about the structure of the sql server database[2005] I need a sql whihc will return the same result for sql server 2000
I have a sql select statement, then I have a datareader and I'm trying to loop through that reader and insert a record into another table each time until there are no more records in the loop. I'm not sure how to do this though without using 2 datareaders. Please help. Thanks 1 ' Retrieve Data from database based on selections chosen in ListBox 2 Dim cmdCommittee As New SqlCommand("Select * from committees_tbl where committee_id in" & _ 3 "(" & strCommitteesRemoveLast & ") order by committee_name", conn_Insert) 4 5 ' setup a datareader 6 Dim drCommittee As SqlDataReader = cmdCommittee.ExecuteReader() 7 8 9 ' Loop through datareader and insert rows 10 ' into the xref_person_committees_tbl 11 While drCommittee.Read() 12 Dim strCommitteeName As String = drCommittee("committee_name") 'retrieve committee_name from datareader 13 14 ' Create a sql string 15 Dim strAddCommittee As String = String.Empty 16 strAddCommittee = "Insert into xref_person_committees_tbl (committee_name) values ('" & strCommitteeName & "')" 17 'Response.Write(strAddCommittee & "<br>") 18 19 ' Create a sql command to process the insert 20 Dim sqlAddCommittee As New SqlCommand(strAddCommittee, conn_Insert) 21 Dim drNewCommittee As SqlDataReader = sqlAddCommittee.ExecuteReader() 22 23 24 25 26 End While 27 ' ----------------------------------------------------------------------------------- 28 29 drCommittee.Close()
I want to pass the string "select @@servername" in the print statement, it throws error as:=
Msg 1046, Level 15, State 1, Line 3 Subqueries are not allowed in this context. Only scalar expressions are allowed. Msg 1046, Level 15, State 1, Line 28 Subqueries are not allowed in this context. Only scalar expressions are allowed.
declare @account_name nvarchar(400) = 'Mail Account'; IF exists (select * from msdb.dbo.sysmail_account where name = @account_name) PRint 'Database Mail Account ' + quotename (@account_name) + 'is already setup in the Server:= ' + (select @@servername);
I mean why such restriction? In such queries results will be only 1 so it does not violate the SET operation. correct??
I want to put some trace in the a UDF, so I put print in the function. IT gave error. Can anyone please explain why this happen. But this work with SPs.
I am using the SQLEXPRESS database, and connect from to locations:
Windows Service ASP.NET web application.
whenever I start the windows service I get the error: Cannot open user default database. Login failed. so I am going to visual studio and close the connection. then I close the web browser, and the windows service succeed connect to database. but then, after windows service is connected, I open the web browser application and fails to login because the login system using the same database of windows service, and since the connection is being used by windows service, login is impossible.
Do you know how I can allow 2 connections at the same time for the same database? what are the risks to do that? and how do I handle this risks. thanks alot
Can anyone tell me what is the maximum number of rows that I can code in a T-SQL step if I want to include this in a job? I do not want to use stored procedure for certain task, so I want to put the same code in a T-SQL step. Thanks! Sheila.
Inserting info into a table, where one of the columns meets a certain criteria.
insert into employee (/*emp_id,*/ fname, lname, start_date, dept_id, title, assigned_branch_id) values (/*null,*/ 'Michael', 'Smith', '2001-06-22', (select dept_id from department where name = 'Administration'), 'President', (select branch_id from branch where name = 'Headquarters'));
But I'm getting this error:
Msg 1046, Level 15, State 1, Line 5 Subqueries are not allowed in this context. Only scalar expressions are allowed.
I am trying to make the following SQL statement, but there seems to a limiton how long a statement can be:INSERT INTO CUSTOMER (forename, surname, company_name, title, addressA,addressB, postal_number, city, country, home_phone, mobile_phone,work_phone, fax, email, sale_procentage, bank, account_number,creation_initials, creation_date, creation_reason) values ("test", "test","test", etc...);But I can only enter this much text:INSERT INTO CUSTOMER (forename, surname, company_name, title, addressA,addressB, postal_number, city, country, home_phone, mobile_phone,work_phone, fax, email, sale_procentage, bank, account_number,creation_initials, creation_date, creation_reason) vaIs there some upper limit? And how do I make a long SQL statement like this?JS
I have a simple table, for some reason, certain columns seem to acceptNulls even though they shouldn't, for example the I can set the 'Name'field to Null using my web application or directly in EnterpriseManager. field How do I prevent this? However the 'RecCreated' doessnot permit nulls.CREATE TABLE [dbo].[Group] ([GroupID] [int] IDENTITY (1000, 1) NOT NULL ,[Name] [nvarchar] (50) NOT NULL ,[Description] [nvarchar] (750) NULL ,[RecCreated] [datetime] NOT NULL ,[RecUpdated] [datetime] NOT NULL ,[RecCreatedBy] [int] NOT NULL ,[RecUpdatedBy] [int] NOT NULL ,[RecActive] [int] NOT NULL) ON [PRIMARY]GOthanks for any help you can give on this
Working on partitioning a few large tables. One of the tables included a text column and the €œTEXTIMAGE_ON [PRIMARY]€? clause which would prevent the partitioning of this table. After some research we found that the data was legacy and no longer used. We updated the column on the affected rows to NULLS and altered the column to a VARCHAR(20) I then attempted to run the ALTER TABLE SWITCH and I encountered the error Msg 4947, Level 16, State 1, Line 1 ALTER TABLE SWITCH statement failed. There is no identical index in source table 'LocalDeltanet.dbo.testresultsjoe' for the index 'PKIDX_testSummary' in target table 'LocalDeltanet.dbo.testresults_part'. After a lot of grief and testing I determined that the message was bogus and the real issue is that the 'sys.tables' still has €œlob_data_space_id€? with a value of 1 for this table. I created a copy of the table with the text column and the "TEXTIMAGE_ON", then altered the column to a varchar and another table with just the varchar column and no "TEXTIMAGE_ON" spoecified. After copying the data from the original table, I tried to run the Alter Switch. It failed once again for the table with the text column that was altered to varchar, but it worked for the table that had the column specified as varchar from the start. All other things have been checked and the two source tables in this test are identical execpt for the Text column specification. The alter column changes the definition of the column, but how would you remove the €œlob_data_space_id€? setting, since it appears that this value is causing my issues, is there anyway to update the table in place. I know I can BCP the data out, but that would take too long and would defeat the advantage of using the alter switch method.
BOL States:
The allow updates option is still present in the sp_configure stored procedure, although its functionality is unavailable in Microsoft SQL Server 2005 (the setting has no effect). In SQL Server 2005, direct updates to the system tables are not supported. This means we cannot update the table manually.
Hi, I've read that a SQL Server Express database is limited to GB. If I have a database with about 120 tables which store only simple datatypes (int, money, datetimes, varchar, etc.), no blobs or large files, how can I estimate the amount of data or number of rows it can hold before it runs out?
Just installed SQL Express but cannot connect since it says Remote Connections are not allowed ! This worked before. I have tried different protocols and even SQL Authentication. No luck here and I've been up all night...
I have a form to submit some data to a database located in the App_Data folder. I have the following connection string: <connectionStrings> <add name="ConnectionString" connectionString="Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|Siven.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/> </connectionStrings>
On the form I'm using a DetailsView control and using a SqlDataSource as the datasource, pointing to the above connection string. In realtime, when i submit the data, I receive the following error:
Server Error in '/' Application.
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) I'm using discountasp.net as the host, and I did not elect to use the SQL Server databases, I'm just going to use SQL 2005 express. I dont understand why it's not pointing to the db when it's there (and to make sure, I re-uploaded). Is there something I missed here?
I've created a new website using the new Visual Studio 2005 Express edition. This site uses SQL Server Express (free software) as a storage for personalization data, etc. Now I want to deploy my site, but here it ends for me:My web site hoster does not support the SQL Express edition in a shared hosting environment. I think most people have a website running in a 'shared hosting' plan. How can this large group enjoy the new Express line when SQL Server Express is not supported? "SQL Server Express is not a part of the SPLA SPUR (Services Provider License Agreement)", they all say. Here it ends for me, my ISP and their licence supplier. Even at Microsoft's Response Management Team, 'no' is the answer. What to do now? Move on to an expensive 'dedicated hosting' plan? Write a membershipprovider for MySQL?I feel as if I was given a free ticket for a nice journey but there's no traffic possible. Who can help me out here? What can I do...
Hi all, I am brandnew with SQL2000, so sorry in advance forstupidities....SQL2000, SP3, running on a SBS2003-server with WindowsSharePointServices.I want to make a dataconnection (from within the LAN with InfoPath) froma client to this server. I got the error that whether the server doesnotexists (it does) or no permission. Where can I find (in SQL2000) whichusers have access to the databases ???Help is appreciated, Ger.*** Sent via Developersdex http://www.developersdex.com ***
SqlCException: Duplicated parameter names are not allowed. [ Parameter name = @SOLUTIONID ]
With the following statement:
SELECT [VERSIONID], [SOLUTIONID], [BASEVERSIONID], [VERSIONNUMBER], [NAME], [DESCRIPTION], [CREATEDATE], [UPDATEDATE], [VERSIONCLOSED] FROM VERSIONS WHERE SOLUTIONID = @SOLUTIONID AND VERSIONCLOSED = 1 AND VERSIONID IN (SELECT MAX(VERSIONID) FROM VERSIONS WHERE SOLUTIONID = @SOLUTIONID);
Besides the obvious of adding a new parameter with the same value and a different name - are there any plans to fix this?
Another area where SQLCE seems deficient is non-support of SCOPE_IDENTITY(), which although not important for CE itself is very important for TSQL compatibility with SQL Server - where obviously @@IDENTITY won't cut it.
A related problem to this is that SQL CE doesn't support batch statements - which sadly destroys the useful pattern of inserting a record with an INSERT and doing an identity SELECT in the same batch.
I'm connecting to an Sql Compact database (3.1) from a C# assembly exposed via COM and called from inside a winsock LSP. The database is only used once on instantiation of the class, which happens in the first call to WSPStartup.
The issue I'm having is that under Vista and when running inside IE7 I get the error in the title. However there is no problems with IE7 under windows XP, or with Firefox and MSN Messenger under XP or Vista!
When selecting to run IE as administrator, the problem dissapears, however when using the LogonUser API to impersonate an administrator it doesnt.
This would seem like a permissions issue, strange though that Firefox under vista has no problems.. Also, the following code throws no SecurityException under either browser, indicating the code is running with full trust.
new PermissionSet(PermissionState.Unrestricted).Demand();
Any input would be a huge help, I've been banging my head against this all day..
I have Written WinForm Application that uses SQL Server Compact 3.5. I also deploy Database (SDF) File with this application. Installation Package Created Using InstallShield 2008.
I Deployed SDF in Common App Data Folder. In Administrator mode Application is working fine. But in User Mode I Get Error Message.
"Access to the database file is not allowed. [ File name = C:Documents and SettingsAll Users Application DataGeorgian MicrosystemsCodex 2007 R2 Russian DatabaseCodexRussian2007.sdf ]"
I Also Tested That Application in user mode Can Create File in ("C:Documents and SettingsAll Users Application DataGeorgian MicrosystemsCodex 2007 R2 Russian Database") Directory.
Test Environment is XP SP2
I Tryed to Copy SDF file manualy. Appplication in user mode can access on it if file is copyed in user mode. if this file is copyd in Administator mode even in users Local Directory SQL Engine can't access on it.
Please Help me to Slove this problem.
How to connect using user mdoe to SDF deploed with admin right. (MSI installer).
I have a Windows 2003 64-bit server running SQL 2005. I am trying to run an OpenRowSet query, but I am getting ""cannot create instance of linked server" (null)" The OpenRowSet I am trying to run was running perfectly fine on the same machine before we moved to SQL 2005 and runs fine on many other machines - so I do not think it is an issue with the openrowset itself.
When I've had his issue on other machines, I have run the following:
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure €˜Ad Hoc Distributed Queries€™, 1;
GO
RECONFIGURE;
GO
And I could then run the Ad Hoc queries fine. But, when I try on this machine, I get the SQL error message:
"The configuration option does not exist, or it may be an advanced option."
I looked at the settings in SQL Server Surface Area Configuration and Ad Hoc was selected; so it should be working. I am logged in as Administrator and have sysAdmin permissions in the SQL database. I'm not sure where else to look or what I am missing.
I've looked many places on the web and have tried many 'solutions' without effect.