I need to JOIN a table when certain conditions are met and LEFT JOIN it when other conditions are met. Since I am in a MS Dynamic CRM with filters, I can't use UNION
SELECT stuff.stuffs
FROM MainTable
JOINS othertable
LEFT JOIN othertables
LEFT JOIN TableX as X1 ON (Conditions1.1 = X1.1
AND MainTable....
I am writing a query that will return
if a table or stored proc exists within a database
if a particular role has been assignned execute permissions to execute that particular stored proc.
I guess I need to query the master database and wiggle thru that to get to the database and the table or stored proc that I am looking for. How c...
Hi there
I need to modify function and I need to know what the impact might be by looking other object that depending on this function such as stored procedure, function etc etc. Now, is there anyway I can find this that can go through all codes? I have a lot of stored procedure/functions on this.
There is possibility within storedproc...
Hi All,
I am getting this error when i try to ran my query.
"Query Processor ran out of internal resources".
...
I'm trying to execute an Insert statement, but keep getting a Invalid object name error.
Here's my code:
public string addNewComment(int userID, int pageID, string title, string comment)
{
string query = "INSERT INTO dbo.nokernok_kommentarer (userID, pageID, commentTitle, comment) " +
"VALUES ("+ userID +", "+ pageID +", '"+ ti...
Hello Guys,
I have noticed something over the last few months. Each time we run a script that has a transaction statements let say we stop the query unexpectedly this action actually lock the database.
The only way out is to destroy the transaction each time. I have never experience this before even though I have stopped the query in t...
Technologies: .net 3.5, Visual Studio 2010, Report Viewer Control version 10, c#
I am using adhoc reports in my winform application, now here is the problem:
When my report is rendered in the viewer, the document map displays the report file name as the the root node of the document map. I need to display a more user-friendly descripti...
I have several variables in an SSIS package that I would like inserting into a table.
example:-
@financialMonth, @Status, @Comments
The Variables have been populated along the way with values based on lookups, filename, dates, etc, and I want to store them in a results table.
Is using the execute SQL task the way to do this ?
Do I ...
Hi All,
As we know the Service Broker is enabled for the new databases we create. But recently the service broker got disabled automatically. Even if the database was restored shouldnt the Service Broker be enabled by default?
...
I can't seem to get the GETDATE() syntax to work in a Job Step of type Transact-Sql Script. I put in the command as:
execute insertMostRecentUpdate
@Data='Data',
@Date=GETDATE()-1
But I get an "incorrect syntax near ')'" error when parsing or trying to run it. Any thoughts?
...
I want a single query to produce the following results..
To result in records that are in table1 and in table2 and were not in table3.
There are more than 10,000 records in each table..so i am looking for an efficient one. In all the table Cono is the primary key..
In detail with tables.
TABLE 1:-
Cono
th-123
th-124
th-125
T...
I'm using adapter.InsertCommand to insert some data into a table.
The only problem is that it's executed twice, thus giving me double entries in the DB.
I've tried following the example in the documentation of adapter.InsertCommand and my own code, but get the same result.
This is my code:
public class nokernokDAL
{
SqlConnection ...
Please do not point me to an article on how to create tree structures, or CTEs in SQL I've read plenty!!! I think this may not be so tough for the t-sql at heart but it is definitely tough for me :).
Here is the situation, I have to create a report that looks like this:
This works great when the parameter to my stored procedure (SQL...
Is there a way to copy a SQL Server Database Diagram to another server?
I found this and modified it sightly to copy only one diagram:
INSERT INTO dbB.dbo.sysdiagrams
SELECT [name],[principal_id],[version],[definition]
FROM dbA.dbo.sysdiagrams
Where name = 'MyDiagramName'
But I need to copy it to another Server (Development to Produ...
Hi,
I have a table for contents on a page. The page is divided into sections.
I want to get the last version for each page-section.
Id (int)
Version (int)
SectionID
Id Version SectionID Content
1 1 1 AAA
2 2 1 BBB
3 1 2 CCC
4 2 2 ...
Everyday a company drops a text file with potentially many records (350,000) onto our secure FTP. We've created a windows service that runs early in the AM to read in the text file into our SQL Server 2005 DB tables. We don't do a BULK Insert because the data is relational and we need to check it against what's already in our DB to make ...
Writing my first SQL query to run specifically as a SQL Job and I'm a little out of my depth. I have a table within a SQL Server 2005 Database which is populated each day with data from various buildings. To monitor the system better, I am attempting to write a SQL Job that will run a query (or stored procedure) to verify the following:
...
USE AdventureWorks;
GO
IF OBJECT_ID (N'dbo.AWBuildVersion', N'U') IS NOT NULL
DROP TABLE dbo.AWBuildVersion;
GO
Whats the N symbolize in N'dbo.AWBuildVersion' & N'U' ?
...
We have a development box which is inside our network and a web server farm outside.
What's the best way to keep the development database synchronized with the Live Server's [changing] Database and yet still keep it secure?
Are there 3rd party tools that would facilitate this?
Are SQL Server's built-in synchronization features good e...
I am currently trying to develop a SSIS Package and am lost because I am a no0b. I have two tables, one is updated and one needs to be updated. I need to compare these two tables and find the primary keys that have been added to the first table and that are not present in the second table.
I need these primary keys in the next set of qu...