SQL some tips

xiaoxiao2021-03-06  47

THESE HAS BEEN Picked Up from thread within sqljunkies forums http://www.sqljunkies.com

Problemthe problem is this i need to round Differently (by Halves) Example: 4.24 Rounds to 4.50 and 4.74 Rounds to 4.00

SolutionDeclare @t float set @t = 100.74 SELECT ROUND (@T * 2.0, 0) / 2

Problemi'm Writing a Function That Needs To Take In A Comma SEPERATED LOST AND USI IN A WHERE CLALD LOOK SOMETHING LIKE THIS:

SELECT * from People Where Firstname in ('Larry', 'Curly', 'MoE')

SolutionUse Northwind Go

Declare @xvar varchar (50) set @xvar = 'Anne, Janet, Nancy, Andrew, Robert'

Select * from Employees where @xvar like '%' firstname '%'

Problemneed a Simple Paging SQL Command

SolutionUse Northwind Go

Select * from products a where (Select Count (*) from Products B Where A.ProductID> = B.ProductId) BetWeen 15 and 16

Problemperform Case-Sensitive Comparision Withnin Sql Statement Without Having To Use the Set Command

Solution

Use norhtwind GO

Select * from products as t1 where t1.productname collate sql_ebcdic280_cp1_cs_as = 'chai'

--execute this command to get different collate naming - select * from :: fn_helpcollations ()

Problemhow to call A Stored Procedure Located in a Different Server

Solution

转载请注明原文地址:https://www.9cbs.com/read-83729.html

New Post(0)