[{"data":1,"prerenderedAt":347},["ShallowReactive",2],{"article-sql-server-find-sql-object-names-within-a-database":3},{"article":4,"tags":63,"previous":78,"next":253},{"id":5,"title":6,"author":7,"body":8,"createdAt":51,"description":52,"extension":53,"img":54,"meta":55,"navigation":56,"path":57,"seo":58,"stem":59,"tags":60,"updatedAt":51,"__hash__":62},"articles\u002Farticles\u002Fsql-server-find-sql-object-names-within-a-database.md","SQL Server Find SQL Object Names within a Database","[object Object]",{"type":9,"value":10,"toc":49},"minimark",[11,15,45],[12,13,14],"p",{},"I was returning to an old database, and I wanted to find all instances of a particular column name.  The following SQL is a very fast way to output the object name (with additional data) for locating the item of interest.  Of course you can make more elaborate by filtering query.",[16,17,22],"pre",{"className":18,"code":19,"language":20,"meta":21,"style":21},"language-sql shiki shiki-themes github-light github-dark","SELECT sc.[name] AS column_name, so.[name] , \n    FROM syscolumns sc INNER JOIN sysobjects so ON sc.id=so.id \n    WHERE sc.[name] LIKE '%TestColumnName%'\n","sql","",[23,24,25,33,39],"code",{"__ignoreMap":21},[26,27,30],"span",{"class":28,"line":29},"line",1,[26,31,32],{},"SELECT sc.[name] AS column_name, so.[name] , \n",[26,34,36],{"class":28,"line":35},2,[26,37,38],{},"    FROM syscolumns sc INNER JOIN sysobjects so ON sc.id=so.id \n",[26,40,42],{"class":28,"line":41},3,[26,43,44],{},"    WHERE sc.[name] LIKE '%TestColumnName%'\n",[46,47,48],"style",{},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":21,"searchDepth":35,"depth":35,"links":50},[],"2015-04-20T08:07:17.2600000-04:00","Find SQL Object Names within a database.","md",null,{},true,"\u002Farticles\u002Fsql-server-find-sql-object-names-within-a-database",{"title":6,"description":52},"articles\u002Fsql-server-find-sql-object-names-within-a-database",[61],"sqlserver","QEpNxETpmOeE4y_rIm0Sg2CxcqEoanKMzug024sdRHg",[64],{"id":65,"title":66,"body":67,"description":71,"extension":53,"img":72,"meta":73,"name":61,"navigation":56,"path":74,"seo":75,"stem":76,"__hash__":77},"tags\u002Ftags\u002Fsqlserver.md","Sqlserver",{"type":9,"value":68,"toc":69},[],{"title":21,"searchDepth":35,"depth":35,"links":70},[],"SQL Server is a relational database management system, or RDBMS, developed and marketed by Microsoft.","https:\u002F\u002Fimages.unsplash.com\u002Fphoto-1598313183973-4effcded8d5e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=675&q=80",{},"\u002Ftags\u002Fsqlserver",{"description":71},"tags\u002Fsqlserver","pSzcNnE-XyUgq8RlgK2xBpbJV7_7o5NLS2XlwBxFyAg",{"id":79,"title":80,"author":7,"body":81,"createdAt":245,"description":246,"extension":53,"img":54,"meta":247,"navigation":56,"path":248,"seo":249,"stem":250,"tags":251,"updatedAt":245,"__hash__":252},"articles\u002Farticles\u002Fsql-server-ndash-find-field-value-in-database.md","SQL Server Find Field Value in Database",{"type":9,"value":82,"toc":243},[83,86,89,241],[12,84,85],{},"The following is a SQL Script that can be run in a database to return all tables and columns where a particular value is present. \nThis can be used for strings or values with a small modification.  This type of thing is great when moving applications\u002Fproducts between servers. ",[12,87,88],{},"This is certainly a good script to include in your master table to be used over and over.",[16,90,92],{"className":18,"code":91,"language":20,"meta":21,"style":21},"DECLARE @value VARCHAR(64)\nDECLARE @sql VARCHAR(1024)\nDECLARE @table VARCHAR(64)\nDECLARE @column VARCHAR(64)\nSET @value = 'valuehere'\nCREATE TABLE #t (\n    tablename VARCHAR(64),\n    columnname VARCHAR(64)\n)\nDECLARE TABLES CURSOR FOR \nSELECT o.name, c.name FROM syscolumns c \nINNER JOIN sysobjects o ON c.id = o.id \nWHERE o.type = 'U' AND c.xtype IN (167, 175, 231, 239)\nORDER BY o.name, c.name\nOPEN TABLES\nFETCH NEXT FROM TABLES\nINTO @table, @column WHILE @@FETCH_STATUS = 0 BEGIN SET @sql = 'IF EXISTS(SELECT NULL FROM [' + @table + '] '  \n--SET @sql = @sql + 'WHERE RTRIM(LTRIM([' + @column + '])) = ''' + @value + ''') \n'SET @sql = @sql + 'WHERE RTRIM(LTRIM([' + @column + '])) LIKE ''%' + @value + '%'') \n'SET @sql = @sql + 'INSERT INTO #t VALUES (''' + @table + ''', '''\nSET @sql = @sql + @column + ''')'\nEXEC(@sql)\nFETCH NEXT FROM TABLES INTO @table, @column END CLOSE TABLES DEALLOCATE TABLES SELECT * \nFROM #t \nDROP TABLE #t \n",[23,93,94,99,104,109,115,121,127,133,139,145,151,157,163,169,175,181,187,193,199,205,211,217,223,229,235],{"__ignoreMap":21},[26,95,96],{"class":28,"line":29},[26,97,98],{},"DECLARE @value VARCHAR(64)\n",[26,100,101],{"class":28,"line":35},[26,102,103],{},"DECLARE @sql VARCHAR(1024)\n",[26,105,106],{"class":28,"line":41},[26,107,108],{},"DECLARE @table VARCHAR(64)\n",[26,110,112],{"class":28,"line":111},4,[26,113,114],{},"DECLARE @column VARCHAR(64)\n",[26,116,118],{"class":28,"line":117},5,[26,119,120],{},"SET @value = 'valuehere'\n",[26,122,124],{"class":28,"line":123},6,[26,125,126],{},"CREATE TABLE #t (\n",[26,128,130],{"class":28,"line":129},7,[26,131,132],{},"    tablename VARCHAR(64),\n",[26,134,136],{"class":28,"line":135},8,[26,137,138],{},"    columnname VARCHAR(64)\n",[26,140,142],{"class":28,"line":141},9,[26,143,144],{},")\n",[26,146,148],{"class":28,"line":147},10,[26,149,150],{},"DECLARE TABLES CURSOR FOR \n",[26,152,154],{"class":28,"line":153},11,[26,155,156],{},"SELECT o.name, c.name FROM syscolumns c \n",[26,158,160],{"class":28,"line":159},12,[26,161,162],{},"INNER JOIN sysobjects o ON c.id = o.id \n",[26,164,166],{"class":28,"line":165},13,[26,167,168],{},"WHERE o.type = 'U' AND c.xtype IN (167, 175, 231, 239)\n",[26,170,172],{"class":28,"line":171},14,[26,173,174],{},"ORDER BY o.name, c.name\n",[26,176,178],{"class":28,"line":177},15,[26,179,180],{},"OPEN TABLES\n",[26,182,184],{"class":28,"line":183},16,[26,185,186],{},"FETCH NEXT FROM TABLES\n",[26,188,190],{"class":28,"line":189},17,[26,191,192],{},"INTO @table, @column WHILE @@FETCH_STATUS = 0 BEGIN SET @sql = 'IF EXISTS(SELECT NULL FROM [' + @table + '] '  \n",[26,194,196],{"class":28,"line":195},18,[26,197,198],{},"--SET @sql = @sql + 'WHERE RTRIM(LTRIM([' + @column + '])) = ''' + @value + ''') \n",[26,200,202],{"class":28,"line":201},19,[26,203,204],{},"'SET @sql = @sql + 'WHERE RTRIM(LTRIM([' + @column + '])) LIKE ''%' + @value + '%'') \n",[26,206,208],{"class":28,"line":207},20,[26,209,210],{},"'SET @sql = @sql + 'INSERT INTO #t VALUES (''' + @table + ''', '''\n",[26,212,214],{"class":28,"line":213},21,[26,215,216],{},"SET @sql = @sql + @column + ''')'\n",[26,218,220],{"class":28,"line":219},22,[26,221,222],{},"EXEC(@sql)\n",[26,224,226],{"class":28,"line":225},23,[26,227,228],{},"FETCH NEXT FROM TABLES INTO @table, @column END CLOSE TABLES DEALLOCATE TABLES SELECT * \n",[26,230,232],{"class":28,"line":231},24,[26,233,234],{},"FROM #t \n",[26,236,238],{"class":28,"line":237},25,[26,239,240],{},"DROP TABLE #t\n",[46,242,48],{},{"title":21,"searchDepth":35,"depth":35,"links":244},[],"2015-04-20T08:07:17.3700000-04:00","SQL Script that can be run in a database to return all tables and columns where...",{},"\u002Farticles\u002Fsql-server-ndash-find-field-value-in-database",{"title":80,"description":246},"articles\u002Fsql-server-ndash-find-field-value-in-database",[61],"9WL54maowA8aY8EDRpBT04V-F_6eINuHpi58uWVJ_i8",{"id":254,"title":255,"author":7,"body":256,"createdAt":339,"description":54,"extension":53,"img":288,"meta":340,"navigation":56,"path":341,"seo":342,"stem":343,"tags":344,"updatedAt":339,"__hash__":346},"articles\u002Farticles\u002Fnet-3-5-sp1-how-to-tell-if-it-is-installed.md",".NET 3.5 SP1 How to tell if it is installed?",{"type":9,"value":257,"toc":337},[258,261,269,273,291,301,304,317,326,329],[12,259,260],{},"Ever want to know if you have 3.5 SP1 installed?  Shown below are two ways to determine.",[12,262,263,264,268],{},"1.) Take a look at ",[265,266,267],"strong",{},"HKLM\\SOFTWARE\\MICROSOFT\\NET Framework Setup\\NDP\\v3.5","  ",[270,271,272],"blockquote",{},"   Shown below are two servers.  The top one does not have SP1 installed while the lower one does. ",[270,274,275,278,268],{},[276,277],"br",{},[279,280,282],"a",{"href":281},"\u002Farticles\u002Fimages\u002Fimage_2.png",[283,284],"img",{"title":285,"style":286,"height":287,"alt":285,"src":288,"width":289,"border":290},"image","border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px",224,"\u002Farticles\u002Fimages\u002Fimage_thumb.png",578,0,[12,292,293,294,297],{},"2.) An easy way to see if you have 3.5 SP1 installed is to navigate to ",[279,295],{"title":296,"href":296},"http:\u002F\u002Fwww.hanselman.com\u002Fsmallestdotnet\u002F",[279,298,296],{"href":296,"rel":299},[300],"nofollow",[12,302,303],{},"Near the top of this page you will be given an indication if you have the latest installed.  ",[270,305,306,307,316],{},"   ",[279,308,310],{"href":309},"\u002Farticles\u002Fimages\u002FNET3.5SP1Howtotellifitisinstalled_A860\u002Fimage_4.png",[283,311],{"title":285,"style":312,"height":313,"alt":285,"src":314,"width":315,"border":290},"border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px",174,"\u002Farticles\u002Fimages\u002Fimage_thumb_1.png",362,"       ",[12,318,319,320,325],{},"If you do not have it installed you can use the following link to navigate you to Microsoft Downloads for ",[279,321,324],{"href":322,"target":323},"http:\u002F\u002Fwww.microsoft.com\u002Fdownloads\u002Fdetails.aspx?FamilyId=AB99342F-5D1A-413D-8319-81DA479AB0D7&displaylang=en","_blank","Microsoft .NET Framework 3.5 Service Pack 1",". ",[12,327,328],{},"This link will install a small installer that will need to be executed.  A wizard will step you through the installation and additional downloads.",[12,330,331,332,336],{},"If you prefer a complete download of this SP1 you can use this ",[279,333,335],{"href":334,"target":323},"http:\u002F\u002Fdownload.microsoft.com\u002Fdownload\u002F2\u002F0\u002Fe\u002F20e90413-712f-438c-988e-fdaa79a8ac3d\u002Fdotnetfx35.exe","link",".",{"title":21,"searchDepth":35,"depth":35,"links":338},[],"2015-04-20T08:07:17.0200000-04:00",{},"\u002Farticles\u002Fnet-3-5-sp1-how-to-tell-if-it-is-installed",{"title":255,"description":54},"articles\u002Fnet-3-5-sp1-how-to-tell-if-it-is-installed",[345],"visualstudio","MC9c4Xg0ISnR8LLg7rbn5Q97cgPxY_9Pduqsos6nBgA",1781574768371]