Viewing 15 posts - 181 through 195 (of 358 total)
Here is a tool that I like to use to help with formatting. It seems to copy and paste ok into SSMS. I don't always like the output,...
November 21, 2008 at 6:39 pm
There is a trick to avoid the dynamic sql by using xml.
November 21, 2008 at 6:07 pm
You can do something like this.
Declare @Date datetime
Set @Date = getdate()
Select @Date -
CASE datename(weekday,@Date)
...
November 21, 2008 at 10:31 am
In order to use the default you cannot supply a value to the column. It is converting the '' to the 1900 date and not using the default.
Try this.
create...
November 21, 2008 at 9:40 am
Try this.
Select Name FileNme, size * 8/1024.0 Size_MB, fileproperty(Name,'SpaceUsed') * 8/1024.0 SpaceUsed_MB from sysfiles
November 21, 2008 at 9:20 am
Here is another way. You cannot use a variable name in the USE Statement.
Declare @sql varchar(max)
Set @sql = ''
select @sql = 'Select ''' +...
November 18, 2008 at 7:45 pm
Try this.
Create Table #Tmp (dbname sysname, tablename sysname)
go
sp_msforeachdb 'use ?; Insert into #tmp select ''?'' dbname, name from sys.tables'
Select * from #Tmp
Drop Table #Tmp
November 18, 2008 at 6:32 pm
If you need to make sure you don't cut off the trailing spaces, you can concatenate a character to the end and then subtract 1.
Declare @test-2 nchar(4)
Set
November 10, 2008 at 9:24 pm
Be careful using Datalength because unicode takes up two spots. The following results in a length of 6.
Declare @test-2 nvarchar(3)
Set @test-2 = '123'
Select Datalength(@test)
November 10, 2008 at 9:15 pm
Try this. You have to join all the tables seperately.
SELECT e.Migration,
ed.Migration
FROM ptEncounter e
INNER JOIN...
October 30, 2008 at 8:51 am
I don't know of a function in SQL that will format a number that way. I generally do something like this.
Declare @i int
Set @i = 23
Select Right('0000' + Cast(@i...
October 30, 2008 at 8:47 am
Here is the sample code to create the test tables. I seem to be getting the results as expected. Try running the entire code sample and see if...
October 29, 2008 at 3:14 pm
You can use a common table expression to store the agentid with the max date and then join it back to the original table to limit the results.
create table #a
(ID...
October 24, 2008 at 6:35 pm
True. I guess it depends on what you are looking for. Most of what is done behind the scenes can be accomplished using scripts, which there are more than...
October 23, 2008 at 2:58 pm
Viewing 15 posts - 181 through 195 (of 358 total)