
sona11
Declaring length in sql server
I want to declare max of length in case condition i.e 7 but getting a syntax error near select in this code.
DECLARE @SQ Int(MAX)
SELECT @SQ= MAX(LEN(FIRST_NAME)) FROM #table
SELECT @SQ
-- 7
DROP TABLE #T
SELECT CASE WHEN LEN(SEQ_NUM) = 0 THEN NULL ELSE SEQ_NUM END AS REC_NUM,
CASE WHEN LEN(FIRST_NAME) = 0 THEN NULL ELSE CONVERT(CHAR(SELECT @SQ= MAX(LEN(FIRST_NAME))
FROM #table),RTRIM(UPPER(FIRST_NAME))) END AS FIRST_NAME
INTO #T
FROM #table
--== Need 7 Char(7) -- Max of len
DROP TABLE #T
SELECT CASE WHEN LEN(SEQ_NUM) = 0 THEN NULL ELSE SEQ_NUM END AS REC_NUM,
CASE WHEN LEN(FIRST_NAME) = 0 THEN NULL ELSE CONVERT(CHAR(7),RTRIM(UPPER(FIRST_NAME))) END AS FIRST_NAME
INTO #T
FROM #table
I tried figuring it out and also went through this resource that has similar things but was still unable to find the solution. Can anyone help me out in finding the solution? Thank you.
First Post!

bot
Corresponding tweet for this thread:
Share link for this tweet.
Popular General Dev topics
New
New

I am thinking of switching to Onivim from VSCode Vim since VSCode Vim supports limited Vim features . Would like to hear from the current...
New

Feature Packed
Everything you need to get started without any configuration. A completely usable editor, right out of the box.
Text-base...
New

This article is the fifth of the series aimed to teach Vim from the ground up:
Vim from the ground up
Vim for Beginners
Vim for Interm...
New

Hi, it’s Takuya. I use Neovim to develop my app called Inkdrop. Recently, I’ve got some updates for my Neovim setup since I’ve published ...
New

So, I actually got my Onivim License Key a while back.
Am a Vim user for about 4 years.
For me it was never ready enough for getting ac...
New

Neorg is a tool designed to reimagine organization as you know it. Neo - new, org - organization. Grab some coffee, start writing some no...
New

Here’s my (current) minimal setup:
set ai nocp digraph ek hid ru sc vb wmnu noeb noet nosol
set bs=2 fo=cqrt ls=2 shm=at tw=72 ww=&l...
New

Vim 9.0 released
After many years of gradual improvement Vim now takes a big step with a major release. Besides many small additions the ...
New
Other popular topics

@AstonJ prompted me to open this topic after I mentioned in the lockdown thread how I started to do a lot more for my fitness.
https://f...
New

Bought the Moonlander mechanical keyboard. Cherry Brown MX switches. Arms and wrists have been hurting enough that it’s time I did someth...
New

My first contact with Erlang was about 2 years ago when I used RabbitMQ, which is written in Erlang, for my job. This made me curious and...
New

Here’s our thread for the Keyboardio Atreus. It is a mechanical keyboard based on and a slight update of the original Atreus (Keyboardio ...
New

Not sure if following fits exactly this thread, or if we should have a hobby thread…
For many years I’m designing and building model air...
New

In case anyone else is wondering why Ruby 3 doesn’t show when you do asdf list-all ruby :man_facepalming: do this first:
asdf plugin-upd...
New

Seems like a lot of people caught it - just wondered whether any of you did?
As far as I know I didn’t, but it wouldn’t surprise me if I...
New

A Hero’s Journey
with Chris Pine
@chrispine
Chris Pine, author of Learn to Program, Third Edition, discusses his journey to beco...
New

Hi folks,
I don’t know if I saw this here but, here’s a new programming language, called Roc
Reminds me a bit of Elm and thus Haskell. ...
New

We’ve talked about his book briefly here but it is quickly becoming obsolete - so he’s decided to create a series of 7 podcasts, the firs...
New
Latest in Code Editors
Latest (all)
Categories:
Sub Categories:
- All
- In The News (10779)
- Dev Chat (200)
- Questions (29)
- Resources (118)
- Blogs/Talks (26)
- Jobs (3)
- Events (14)
- Code Editors
- Hardware (57)
- Reviews (3)
- Sales (15)
- Design & UX (4)
- Marketing & SEO (1)
- Industry & Culture (15)
- Ethics & Privacy (19)
- Business (4)
- Learning Methods (4)
- Content Creators (7)
- DevOps & Hosting (9)
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /rails
- /js
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /java
- /haskell
- /emacs
- /svelte
- /onivim
- /typescript
- /crystal
- /c-plus-plus
- /tailwind
- /kotlin
- /gleam
- /react
- /flutter
- /elm
- /ocaml
- /vscode
- /opensuse
- /ash
- /centos
- /php
- /deepseek
- /scala
- /zig
- /html
- /debian
- /nixos
- /lisp
- /agda
- /textmate
- /sublime-text
- /react-native
- /kubuntu
- /arch-linux
- /ubuntu
- /revery
- /manjaro
- /django
- /spring
- /diversity
- /nodejs
- /lua
- /c
- /slackware
- /julia
- /neovim