• Got a Tipila, google, windows live or facebook account ?
Tips tagged: sql-server
1
votes
This is how to check a column exists in tsql if Exists(select * from sys.columns where Name = N'columnName' and Object_ID = Object_ID(N'tableName')) begin -- your code end
1
votes
This is how to update a column of a table to be the group-by-count of rows, in another table. User table has a field called postcount which represents the number of posts that a user has made. And the Tip table has all the posts. So we are going to get the number of posts that a user has made from the Tip table and set ...
0
votes
with counts as ( select tag.Id, count(tip_tag.TipId) as cn from tag left outer join tip_tag on tag.Id = tip_tag.tagId group by tag.id ) update tag set tipcount = (select cn from counts where counts.Id = tag.Id)
0
votes
This is how to re-build a fulltext catalog , [FTCat_Tip] is the name of the catalog ALTER FULLTEXT CATALOG [FTCat_Tip] REBUILD WITH ACCENT_SENSITIVITY = ON
1
votes
Following will create the login tom with password 0101 if it does not exist or associate the use with an existing login with the same name USE mydatabase; GO EXEC sp_change_users_login 'Auto_Fix', 'tom', NULL, '0101'; GO more info http://msdn.microsoft.com/en-us/library/ms174378.aspx
1
votes
Here's how to backup all the db s on the server to a single .bak file using tsql in sql server. DECLARE @name VARCHAR(50) DECLARE @path VARCHAR(256) DECLARE @fileName VARCHAR(256) DECLARE @fileDate VARCHAR(20) SET @path = 'h:\Backup\' SELECT @fileDate = CONVERT(VARCHAR(20),GETDATE(),112) DECLARE db_cursor CURSOR FOR SE ...
0
votes
Use this to fix the above error in SQL server ALTER DATABASE dbname SET EMERGENCY; GO ALTER DATABASE dbname SET SINGLE_USER; GO DBCC CHECKDB (dbname , REPAIR_ALLOW_DATA_LOSS) WITH NO_INFOMSGS; GO use dbname go DBCC CHECKDB ALTER DATABASE dbname SET MULTI_USER; GO Note DO NOT do this to a production db as it might cause ...
1
votes
Here's how to do a union query with an order by clause SELECT * FROM (SELECT TOP 1 StartDate FROM dbo.ExportStatus WHERE PubSurveyVersion = @PublicationId ORDER BY StartDate DESC) t1 UNION SELECT * FROM (SELECT TOP 1 QueuedTime FROM dbo.ExportQueue WHERE PubSrvId = @PublicationId ORDER BY QueuedTime DESC) t2
1
votes
Here's how to get the number of days between 2 dates in sql server DATEDIFF(day,startdate,enddate) or DATEDIFF(d,startdate,enddate) or DATEDIFF(dd,startdate,enddate)
1
votes
Add '' (empty single quotes)as the dafault value in SSMS properties window alter table employee add columname varchar(50) default ''
1
votes
Enter the following command in SSMS sp_configure 'show advanced options', 1; GO RECONFIGURE; GO sp_configure 'clr enabled', 1; GO RECONFIGURE; GO
11
Matching Tips
Search options
  • Use the syntax:
    seach text, tag1, tag2,...
    to search for tips with the given tags.
  • Add ,mytips to the search text to search within MyTips only.
  • Use the syntax:
    ,tag1, tag2,...  to get all tips with the given tags.
Login to Tipila