Is there any way to convert differential backup to SQL statements which will produce identical results when applied?
Or any other solution similar to binary log in MySQL?
I just copied my current database to a new database to find out only the tables are copied,
How do I copy all stored procs the same way in one go?
I do not want to create each stored proc one by one again running create queries
Thank you in advance
This is in MS SQL
How would I do this in a stored procedure (SQL 2005):
count = select count(*) from table1 where line like '%success%'
if count > 0:
delete from table1 where not line like '%success%'
Thanks for any help. My google skills are really failing me today :-(
How to insert rows in an Excel sheet into SQL Server 2005 or oracle ?
For example if I have 5000 rows in Excel sheet how can I insert these rows into a table in any database
Good day!
Despite the fact LINQ2SQL and ADO.NET Entity Framework exists there were situations when I need to revert to plain old DataSet (not typed) and friends.
While writing SQL for SqlCommand:
Is it needed to quote field and table names with []?
Is it good to prefix table names with [dbo]
I use to use this syntax:
SqlCommand command = new SqlCommand("SELECT [Field1], [Field2] FROM [dbo].[TableName]", connection);
May be there is a better way?
Thanks in advance!
hi, is it possible to alias an aggregate function in a select clause as AliasTable.AliasColumn? The reason is because I want minimum modifications in my arrays (I'm using PHP). Thanks!
P.S.
I'm using SQl Server 2008
I am trying you insert some string which is not in English (other language). when i fetch back they are not correct. They comes like "?????".
But at the same time when I enter the string through the SQL Server UI (SSMS) to enter the string, it works OK.
What could be the solution please?
I am storing images in a SQL database , right now I have images being stored in separate tables depending on the object the images belong to, is there any reason ( performance etc..) why I should keep it this way and not store all images in the same table?
What are those pro/subtle techniques that SQL provides and not many know about which also cut code and improve performance?
eg: I have just learned how to use CASE statements inside aggregate functions and it totally changed my approach on things.
Are there others?
How can i update bulk data in sql server 2005 by sending the data in XML form ?
i am able to insert bulk data into the table, but i am not getting idea to update the data.
Is there a way to get the profiler without installing Microsoft Sql Server?
If the answer is no, which edition do I need to get the profiler? Do I need the Developer Edition?
I have a table; let it be called table1; with the following fields and data
I need a query that returns the record with the maximum value in Field3 for each group of records having the same value in Field2. So that the query returns:
How could this be done using SQL queries ?
I would like to do something like this i.e., use wild card characters in the in clause:
SELECT * FROM mytable WHERE keywords IN ('%test%', '%testing%')
This is not supported in MS SQL.... Is there some other way to achieve it...
Looking for something other than:
SELECT * FROM mytable WHERE keywords like '%test%' or keywords like '%testing%' or.....
I want to use infinite WHILE loop in SQL 2005 and use BREAK keyword to exit from it on certain condition.
while true does not work, so I have to use while 1=1.
Is there a better way to organize infinite loop ?
I know that I can use goto, but while 1=1 begin .. end looks better structurally.
I have an Oracle SQL query as part of a stored proc:
DELETE FROM item i WHERE NOT EXISTS (SELECT 1 FROM item_queue q WHERE q.n=i.n) AND NOT EXISTS (SELECT 1 FROM tool_queue t WHERE t.n=i.n);
A bit about the tables:
item contains about 10k rows with an index on the n column
item_queue contains about 1mil rows also with index on n column
tool_queue contains about 5mil rows indexed as well
I am wondering if the query/subqueries can be optimized somehow to make them run faster, I thought that deletes were generally fairly fast
I need to performance tune following SQL query by removing "OR" statements
Please help ...
SELECT a.id, a.fileType, a.uploadTime, a.filename, a.userId, a.CID, ui.username, company.name companyName, a.screenName
FROM TM_transactionLog a, TM_userInfo ui, TM_company company, TM_airlineCompany ac
WHERE
(
a.CID = 3049
)
OR
(
a.CID = company.ID
AND
ac.SERVICECID = 3049
AND
company.SPECIFICCID = ac.ID
)
OR
(
a.USERID = ui.ID
AND
ui.CID = 3049
);
For example, imagine that I want to see if a user exists in my database:
Select * from Users where inputID = Users.ID
Then if that result brought 0 items, then the user exists, correct?
How can I do something like this using a pure Linq-to-SQL class?
i am doing this:
CREATE TABLE person
(
num INT NOT NULL ,
firstname VARCHAR(20) NULL ,
lastname VARCHAR(30) NULL
);
sql server is just saying "debbuging" and it's not doing anything
is there a problem with the syntax or what?
I use SQL Server 2000.
Suppose I have two tables like the following:
Area
----------------------------------
ID| Name | HierarchyLevel
----------------------------------
1 | World | 1
2 | America| 2
3 | Europe | 2
4 | Africa | 2
5 | USA | 3
and
AreaHierarchy
------------------------
ID | ParentID | ChildID
------------------------
1 | 1 | 2
2 | 1 | 3
3 | 1 | 4
4 | 2 | 5
where
AreaHierarchy.ParentID and AreaHierarchy.ChildID are FKs of Area.ID
How can I find the nth parent of USA?
Is it possible without looping?
Probably not.
Suppose I have got a table which I have to insert the description of the contract under different keys of contract.
But when executing, there is a n error near then
Is there any limitation of using syntax set ?
The below is my SQL
declare @i int, @j v nvarchar(MAX)
set @i = 1
while (@i<=8)
begin
set @j = case when @i = 1 then 'CR' when @i = 2 then 'Facebook' else 'N/A' end
INSERT INTO CostNature (CNKey, CNNDescription) VALUES (@i , @j );
set @i = @i + 1
end
I am trying to insert NULL value in Sql Server if I have null value in corresponding C# String object like below :
String Residence = xmlDoc.Descendants("Appointment").Single().Element("StateOfResidence") == null ? null : xmlDoc.Descendants("Appointment").Elements("StateOfResidence").Single().Value;
I am using Entity framework for Database access. So if Residence is null, 'NULL' gets inserted into Database instead of NULL. How can insert NULL for null ?
I am getting the error from the application as following with SQL server 2005
"Transaction count after EXECUTE
indicates that a COMMIT or ROLLBACK
TRANSACTION statement is missing.
Previous count = 1, current count =
0"
How can i find the stage where this error raised?
how can i found the missing transaction or the stored procedure where it is not committ or rollback?
I have a SQL Server 2012 Sequence object:
/****** Create Sequence Object ******/
CREATE SEQUENCE TestSeq
START WITH 1
INCREMENT BY 1;
I have a SP that runs some queries inside a transaction:
BEGIN TRAN
SELECT NEXT VALUE FOR dbo.TestSeq
<here all the query update code......>
ROLLBACK TRAN
If the transaction fails all the updates are rolledback without problem but the Sequence is not rolled back I guess because Its out of the scope of the transaction.
Any clue on way to handle that?
Thanks
I have a table for animals like
Lion
Tiger
Elephant
Jaguar
List item
Cheetah
Puma
Rhino
I want to insert new animals in this table and I am t reading the animal names from a CSV file.
Suppose I got following names in the file
Lion,Tiger,Jaguar
as these animals are already in "Animals" table, What should be a single SQL query that will determine if the animals are already exist in the table.