IDE: Microsoft SQL Server Management Studio  Mistakenly I have cleaned a table data using  delete from table tblBookData   and now it has cleaned that table, please tell me is there any way to get back that data?   If yes than please tell me the process, as I have studied there is a way to get back data if we have not closed the session.
5182
I mistakenly deleted around 2,000,000 records from a remote SQL Server 2008 table.  The server is not granting me access to the backup files on the server side.   Is there any way to get back these records?
96882
Using some methods, when you create a copy of a table you lose indexes, PK, FK, etc. For example in SQL Server I can say:  select * into dbo.table2 from dbo.table1;   This is just a simple copy of the table; all of the indexes / constraints are missing. How can I copy a table structure (without using a backup)?  I am primarily looking to do this manually, but if that's not possible I'll accept any solution.
91873
We had several power outages and server rebooted couple times which seemed to cause issues with one of the databases.  We tried detaching at attaching database again but it looks like database is corrupted and we’re getting the  Msg 5172, Level 16, State 15, Line 1  Claiming that database header is invalid. Is there anything we can to do repair database or extract data from MDF file?  We do have a backup but it’s like 2 weeks old and doesn’t contain all data.
60878
I've recently finished a project, during which many DB tables were created.   Most of these tables contain temporary garbage, and I am looking for a simple way to list all these tables.  Is there a way to list all DB tables sorted according to their creation date?
78798
I have a table structured as so (Simplified)  Name, EMail, LastLoggedInAt   I have a user in SQL Server (RemoteUser) that should only be able to see data (Via a select query) where the LastLoggdInAt field is not null.   It looks like I can do this? Is it possible?
59719
I've just inherited a database with a number of tables and stored procedures.  I use Microsoft SQL Server Management Studio.  One, or possibly more, stored procedures update a specific table.  I'd like to do a textual search through all the stored procedures to look for the procedure that updates the table.  If the raw SQL was in our code, I'd just grep the code base, but with stored procedures I'm not sure how to search through all the stored procedures.  I'd also like to rename a few things and do a find/replace throughout the stored procedures.  Is it possible to search and replace in stored procedures using Microsoft SQL Server Management Studio?
53881
When I have a class I believe I no longer use, I usually attempt to delete it and see if there is an error. This strikes me as one of those things that just must be wrong...but I don't see another way. Can someone tell me what I must obviously be missing? :(
122505
I did the following   1)Deleted a record in sfdc and then ran the query using ' ALL ROWS' keyword and i could see that as per the documentation that data from recycle bin is also retrieved with isdeleted=true  2)I deleted the record from recycle bin and now i observed that still i was able to retrieve it .  Can anybody aware why this happens ?  Also if i filter the records by date and use ALL ROWS will the date filter still apply?
75648
I am trying to get a greater understanding on the differences between the DELETE and TRUNCATE commands. My understanding of the internals goes something along the lines of:  DELETE -> the database engine finds and removes the row from the relevant data pages and all index pages where the row is entered. Thus, the more indexes the longer the delete takes.  TRUNCATE -> simply removes all the table's data pages en mass making this a more efficient option for deleting the contents of a table.  Assuming the above is correct (please correct me if not):   How do different recovery modes affect each statement? If there is any effect at all When deleting, are all indexes scanned or only those where the row is? I would assume all indexes are scanned (and not seeked?) How are the commands replicated? Is the SQL command sent and processed on each subscriber? Or is MSSQL a bit more intelligent than that?
124269
How do I select all the columns in a table that only contain NULL values for all the rows?  I'm using MS SQL Server 2005.  I'm trying to find out which columns are not used in the table so I can delete them.
104379
Can I use this approach efficiently?  using(SqlCommand cmd = new SqlCommand("GetSomething", new SqlConnection(Config.ConnectionString)) {     cmd.Connection.Open();     // set up parameters and CommandType to StoredProcedure etc. etc.     cmd.ExecuteNonQuery(); }   My concern is : Will the Dispose method of the SqlCommand (which is called when exiting the using block) close the underlying SqlConnection object or not?
15336
In SQL Server 2005, is there a way to find users that either don't exist at the server level (an account that was deleted at server level but wasn't disassociated from databases before it was deleted) or accounts that aren't linked (an account may have been deleted at the server level but not db level, then readded but the db level was never cleaned up).  I've got a very messy server and it would be awesome if there was a query to run to find these.
15483
I'm experiencing an annoying problem with a table named SysMessages in one of our databases. When I run a select statement I don't get the contents of this table, but of the sys.sysmessages view in the master database. A use [DBNAME] doesn't help, nor select * from [DBNAME].dbo.SysMessages.  I'm in the middle of a migration to a newer SQL Server version. In SQL Server 2008 R2 I didn't encounter this problem with this database, but in SQL Server 2016 I'm not able to query my own SysMessages table.  Any help would be greatly appreciated.
87554
We have 2 servers:  Server A. production (no partitions) Server B. New Server (partitions and compression)  We restored a backup to the new server, partitioned a large table by datetime and turned on compression, and we were happy. Trying to be clever, we turned on replication to update the new server with the latest data on the large table, but that broke the partitioning and compression. We cannot query any old data on the new server, only data from when we turned on replication. The clustered index is the old one, and compression is not on, and no partitions to be seen in SSMS, it's using the PRIMARY filegroup  (same as the current live server is using). On the physical disk, I can see the partition files, and they are still massive with GBs of data, so I know the data is there, but it appears the table has lost the link to it. It appears turning on replication replicated the filegroup side of things. Is there a way to point the table back to partitions and save all the work we did getting it ready for switch over? It's a pretty large database. This one table is 11TB on the production server. SQL Server 2017 Enterprise Edition.
115024
I have a table with a row Page_Number_N some of the rows have values and others just have a space. For example record 4 is just a space. Field values are Strings.  1 2 3  5   When I start an edit session and delete the space it deletes it. However, as soon as I save edits, the space in the data returns.  I have tried removing the space in the field calc without edit session turned on and the result is the same.  I need this record to equal "" ie. No spaces or null and I can't seem to get ArcGIS Desktop to cooperate.  Does anyone know how to fix this?
32195
I have SQL Server 2012 backup files and want to restore these to SQL Server 2016/2014. Will it work?  I need to find this out before I uninstall SQL Server 2012.
69435
Help! My master database is corrupt, I can't even bring the SQL instance online! What are my options to get my server back up?   I do have a backup of master, but the  asks me to start the instance in single-user mode, which I can't do!  (Note: I'm leaving this question unspecified as to SQL version, so as to be a more widely-applicable reference. There are some similar questions on DBA.SE, but none that involve the server unable to start.)